How to set line breaks, new pages and spaces in LaTeX
Explain clearly which commands are used for paragraphs, line breaks within paragraphs, paging and horizontal spaces in LaTeX, explain why hitting enter and spaces too many times does not take effect, and provide an item-by-item check method to help you quickly adjust the layout according to your needs.
Key points of this article
- Use blank lines to separate paragraphs, and use
\\to force line breaks within paragraphs. The two have different functions. Mixing them will cause abnormal paragraph spacing. - Multiple spaces in the source file will be merged into one. Use
\quad,\hspace{}and other commands when you need a fixed width of space. - Use
\newpagewhen starting a new page; use\clearpagewhen there are charts waiting for typesetting to prevent charts from being squeezed to the back. - Use
~to connect phrases such as "Picture~1" and "Chapter ~3~" to prevent them from being split at the end of the line. - The command effect should be based on the compiled PDF. Check the paragraph spacing, line break position and page break point page by page.
When many people use LaTeX to write a paper for the first time, they will find that there is no line break when hitting Enter in the source file, and only one of several consecutive spaces is displayed in the PDF. This is not a software error, but the formatting rules of LaTeX: newlines and spaces in the source file are just delimiters, and the final layout is determined by the command. People who search for "how to wrap lines in latex" and "how to add spaces in latex" are usually looking for these types of writing methods for typesetting control.
This is for anyone who is writing an essay, report or dissertation template. After reading, you should be able to distinguish three needs: starting a new paragraph, breaking a line within a paragraph, and starting a new page, and know which command to use for each. You can also figure out why spaces are merged, how to insert whitespace of a specified width, and what settings control text spacing.
How to wrap lines, start a new page, and add spaces in LaTeX? One sentence conclusion
Use \\ to force a line break between paragraphs, \newpage or \clearpage to start a new page, and \quad or \hspace{} to use a fixed-width blank. The table below provides methods based on your specific situation.
| your situation | Recommended practices | reason |
|---|---|---|
| Want to start a new chapter | Leave an empty line in the source file | A blank line indicates the end of a paragraph, and LaTeX will automatically handle paragraph spacing and first line indentation. |
| Line breaks are required within the same paragraph, such as addresses and poems. | Add \\ at the end of the line | Forced line breaks, no new paragraphs will be generated |
| Start on a new page between chapters | \newpage | Immediate page change, suitable for manual control of paging position |
| There are charts in the front that have not been displayed yet and need to be changed to a new page. | \clearpage | First output the waiting floating body, and then change the page |
| Requires a fixed-width whitespace | \quad (yuē 1 em) huò\hspace{2em} | The width is clear and is not affected by the number of spaces in the source file. |
| The two words do not want to be separated at the end of the line | Use ~ to replace spaces | Non-breaking spaces, such as "Picture~1" will wrap together. |
Before you start: Confirm these points first
1. Confirm the compilation engine. Chinese documents usually use the ctex macro package and are compiled with XeLaTeX or LuaLaTeX. There is no need for spaces between Chinese characters, and line breaks are handled by the macro package. Different engines handle Chinese line breaks and fonts differently. The same command may have different effects in different compilation methods, so first confirm which one you are using.
2. Distinguish between "paragraph" and "line". Paragraph is the typesetting unit of LaTeX, and lines are automatically folded according to the page width. If you want a new paragraph, use a blank line. If you want to break within a paragraph, use \\. If \\ is used to replace blank lines, the paragraph spacing will be smaller and the first line indentation may be lost.
3. Why does typing multiple spaces have no effect? LaTeX will merge consecutive whitespace into a single space, and whitespace at the beginning and end of the line will also be ignored. Therefore, you cannot rely on typing more spaces to increase the spacing. You need to use explicit commands such as \quad, \hspace{} or ~.
4. Check the document type. The three types of documents article, report, and book handle paging commands differently. For example, \cleardoublepage in the book class will cause the content to start from odd-numbered pages, which is suitable for double-sided printed dissertations; using it in the article class will not have obvious effects.
5. Pay attention to macro package dependencies. Commands such as \needspace and \microtypesetup need to be loaded with \usepackage in the preamble area first, otherwise Undefined control sequence will be reported during compilation. This type of error indicates that the macro package is missing, not that the command is written incorrectly.
Steps to set line breaks, paging and spaces in .tex source files
- Open the
.texsource file and find the location that needs to be adjusted. Pay attention to distinguish whether it is between two paragraphs or in the middle of a paragraph. - Leave a blank line between two paragraphs. Only one blank line is needed. Multiple consecutive blank lines have the same effect as one blank line and will not increase the spacing.
- When it is necessary to break a line within a paragraph, add
\\after the broken word, such as第一行内容 \\ 第二行内容. If you want to leave a little more space after the line break, you can write\\[6pt]. - When you need to start another page, write
\newpageon a separate line. If there are previous charts that have not been output yet, use\clearpageinstead to let the charts be output first and then change the page. - When you need to fix the blank space, use
\quadto get a blank space of about one font body width, or use\hspace{1cm}to specify a specific length. Do not use multiple spaces instead. - Use
~to connect phrases that you do not want to disconnect, such as "Figure~1", "Chapter ~3~" and "Eq.~(2)". - Recompile, open the generated PDF and check the results page by page. If you are processing LaTeX content in UniDoc web editor, it is still recommended to compile and check locally using the above method after exporting.
Check each item after completion
The effect of LaTeX commands is subject to the compiled PDF. Just because the source file looks correct does not mean that the layout is correct. The table below lists common inspection items.
| Check items | How to see | What to do if there is a problem |
|---|---|---|
| segment spacing | Are the spaces between adjacent paragraphs consistent? | If the paragraph spacing is too large, check whether there is an extra \\ at the end of the paragraph; if the paragraph spacing is too small, add a blank line |
| Execution position | Whether the forced line break is at the appropriate position and whether there are only one or two words left in the last line | Adjust the position of \\, or use ~ to tie related phrases together |
| paging position | Whether the chapter starts on a new page and whether the figure is too far away from its reference | Use \clearpage instead, or adjust the chart's placement parameters |
| Blank bottom of page | Does a large blank space remain after page change? | Remove unnecessary \newpage and let the content be arranged naturally |
| white space width | Are indentations and spacing consistent with other locations? | Use \quad or \hspace{} uniformly to delete the spaces that are manually typed multiple times. |
| Mixed Chinese and English | Are the intervals between Chinese, English, and numbers natural? | Check the settings of macro packages such as ctex and do not use multiple spaces to harden the spacing. |
If your document is LaTeX source code translated from another language, compare the layout of the original text and the translated version. OmniDoc supports translating LaTeX source code packages, and the output will retain typesetting, formulas, and images. After the translation is completed, you can use the two PDF comparison functions in desktop client to compare them page by page. Machine-translated content still requires manual verification, especially the text descriptions next to professional terms and formulas.
📊 Core comparison
| method | Effect | Applicable scenarios |
|---|---|---|
| blank line | End current paragraph and start new paragraph with paragraph spacing | General paragraphing in text |
\\ or \newline | Forced line breaks within paragraphs without generating new paragraphs | Addresses, poems, formula line breaks, etc. need to remain in the same paragraph. |
\newpage | Switch to new page now | When a separate page is required between chapters or a certain paragraph of content |
\clearpage | Output the waiting chart and then change the page. | Documents with many diagrams and want to keep diagrams and references close to each other |
\cleardoublepage | Go to next odd page | Double-sided printing papers of the book category |
❓ Frequently Asked Questions (FAQ)
1. Why is there still no line break in the PDF after I press Enter in the source file?
LaTeX treats a single newline character as a space, and only a blank line ends a paragraph. When you need to break a line within a paragraph, please explicitly write \\ at the end of the line.
2. After using \\ to break a line, will the next line be re-indented?
Won't. \\ only breaks lines within the same paragraph, and the following text is typed after the previous line, and the first line of the new paragraph will not be indented. If you want the following content to be a new paragraph with indentation, leave a blank line.
3. Do I need to manually add spaces between Chinese and English?
Generally not required. When using the ctex macro package, the spacing between Chinese and English is automatically processed by the macro package. Manually adding spaces may make the spacing too large. If you really want to add a little fine spacing, you can use \,, which represents a small fixed margin.
4. If I want to adjust the overall line spacing, where should I change it?
Line spacing should be set uniformly in the introduction area and should not be modified paragraph by paragraph in the main text. A common approach is to load the setspace macro package and use commands such as \onehalfspacing to set the line spacing of the full text; page margins can be adjusted using the geometry macro package. The distance between words is mainly determined by the font and alignment. Manual stretching is generally not recommended.
📝 Summary
LaTeX's line breaks, paging, and spaces are all controlled by commands. Carriage returns and multiple spaces in the source file do not directly determine the layout. Set according to the rules of "blank line segmentation, \\ line break, \newpage or \clearpage page change, \quad and \hspace blank space, ~ binding phrase", and then check the compiled PDF page by page to get a stable layout.
Open OmniDoc and edit, convert or translate your LaTeX document


