178 votes

Forcing linebreaks in \url

Herbert Voß created (December 2017) the package xurl. This package allows urls to break everywhere, can be compiled simply with pdflatex, and has the same options as url (indeed, it loads url package)...
CarLaTeX's user avatar
  • 61.3k
118 votes

Multiple lines one side of equation with a Curly Bracket

Use the cases environment, like this. \documentclass{article} \usepackage{amsmath} \begin{document} \begin{equation} D_{it} = \begin{cases} 1 & \text{if bank $i$ issues ABs at time $t$...
gernot's user avatar
  • 48.7k
73 votes

How to force LaTeX not to break the line after a hyphen “-”?

Do not reinvent the wheel – there is a package for that It is called the extdash package and adds multiple commands for new behaviour with dashes. Important: load this package as the very last ...
MaxNoe's user avatar
  • 6,096
62 votes
Accepted

What does "overfull hbox" mean? (Why is there a black mark at the end of a line?)

Quoting Phil Miller answer, for completeness: This message means that a line of your document is too long to fit within the horizontal space on the page, and TeX couldn't find a good way to break it ...
user's user avatar
  • 4,675
58 votes

How to force LaTeX not to break the line after a hyphen “-”?

The amsmath package provides the \nobreakdash command to insert before the relevant dash: \documentclass{article} \usepackage{amsmath} \usepackage[width=1.5cm]{geometry} \begin{document} A (re\...
Andrew Swann's user avatar
  • 94.9k
56 votes

How can I prevent inline math formulas from overflowing into the margin?

If your formular is not too long for a line in the first place, you can use \sloppy in the begining of your paragraph: The lineshape of the imaginary part of the susceptibility (e.g. $\mathrm{\...
Walter Lars Lee's user avatar
55 votes
Accepted

newline in multirow environment

There is several ways to do it. A very simple way is using \shortstack \documentclass{article} \usepackage[frenchb]{babel} \usepackage[T1]{fontenc} \usepackage{multirow} \begin{document} \begin{...
flav's user avatar
  • 4,644
40 votes
Accepted

How to adjust the line breaking in the bibliography?

This is a general problem of automatically generated bibliographies. Some bits of the bibliography entry may turn out to be unbreakable and if they happen to occur in the wrong place, overfull or ...
moewe's user avatar
  • 173k
38 votes
Accepted

how to maintain text justification after forcing a new line

\\ (which you should almost never use) is for leaving the line short. \linebreak (which you should almost never use) is the command to force a line and still justify the paragraph. \linebreak has an ...
David Carlisle's user avatar
38 votes
Accepted

Typesetting curiosity: word change on one line does not affect how that line is set, but affects how the next line is set

I could not reproduce the output that you show, however by exaggerating width of her I can produce the effect, \documentclass[12pt]{book} \RequirePackage[adobe-utopia]{mathdesign} \textwidth5.5in \...
David Carlisle's user avatar
36 votes

Algorithm return statement does not begin on new line

\State \Return your-text will fix it.
Hooman's user avatar
  • 361
35 votes

What are underfull hboxes and vboxes and how can I get rid of them?

Often, TeX outputs underfull hbox and vbox warnings when running and in the generated log file. What are these and how can I get rid of them? That's just TeX alerting you that it was unable to ...
Quuxplusone's user avatar
34 votes

break lines in minted code

Version 2.1 of minted has breaklines and linenos: \documentclass[a5paper]{article} \usepackage[T1]{fontenc} \usepackage[]{minted} \begin{document} \begin{minted}[linenos,tabsize=2,breaklines]{text} ...
egreg's user avatar
  • 1.1m
34 votes

newline in multirow environment

Simple with makecell, which is done for this sort of things: use the \multirowcell command (syntax even simpler than \multirow): \documentclass{article} \usepackage[frenchb]{babel} \usepackage[T1]{...
Bernard's user avatar
  • 270k
33 votes

How to put a line-break in section heading?

I recently ran into a similar issue where my section title was being split across two lines, but only one or two words were ending up on the second line. I wanted to manually insert a line break so ...
DaoWen's user avatar
  • 441
32 votes
Accepted

The word "Wikipedia" does not hyphenate

It's true that by default “Wikipedia” is not hyphenated: \documentclass{article} \usepackage{showframe} \begin{document} wikipedia wikipedia wikipedia wikipedia wikipedia wikipedia wikipedia ...
egreg's user avatar
  • 1.1m
31 votes

How to create nonbreaking arbitrary length snakes for full-width justification?

Really is not a snake, but ... \documentclass{article} \usepackage[text={1.2in,3in}]{geometry} \def\snake{\cleaders\hbox to .5em{\hss\ensuremath\sim\hss% \hspace{-.3em minus -.2em}% }\hfill$^{_\...
Fran's user avatar
  • 79.4k
31 votes

How to create nonbreaking arbitrary length snakes for full-width justification?

While I couldn't get David Carlisle's answer to work, I made a simple tielable vector version of the xkcd snake: \documentclass{article} \usepackage[text={1.2in,3in}]{geometry} \usepackage[none]{...
wrtlprnft's user avatar
  • 3,839
29 votes

How to add a forced line break inside a table cell

Here I use stacks to accomplish it. Several things are noteworthy: I demonstrate \Longstack , \Longunderstack and \Centerstack, which give three different alignments. In order not to squeeze against ...
Steven B. Segletes's user avatar
26 votes

URLs in bibliography: LaTeX not breaking line as expected

When using biblatex, this can also be achieved with the block=ragged option, see §3.1.2.1 in http://mirrors.ibiblio.org/CTAN/macros/latex/contrib/biblatex/doc/biblatex.pdf i.e. \usepackage[block=...
Andreas's user avatar
  • 361
25 votes

How can I make my text never go over the right margin by always hyphenating or breaking on word-boundaries?

The accepted answer suggests \sloppy. However, as per this related answer, \sloppy can produce imperfect results, and it's often preferable to use \emergencystretch 3em instead. Please have a look at ...
Sparhawk's user avatar
  • 494
25 votes
Accepted

What is \arraybackslash doing on my table column?

As with almost everything in TeX, control sequences (macros and control words) can be redefined, and because local grouping allows for local redefinition, the definitions of macros within a particular ...
Alan Munn's user avatar
  • 215k
24 votes

How can I force a new line after a subsection?

Add the following code; \hfill\\ after the \subsection{...} command. The \hfill fills the line with empty space, so that \\ can end this line without an error.
Lars Diening's user avatar
23 votes

Why does \\ not return a new line in an equation?

There is an easy way to make \\ works in equation (change line): \begin{equation} a = b \end{equation} Change it to \begin{equation} \begin{array}{l} a = \\ b \end{array} \end{...
Shuan He's user avatar
  • 247
23 votes
Accepted

How to create nonbreaking arbitrary length snakes for full-width justification?

this is lualatex only and draws a PDF line w points wide to pad out each line, if you are feeling artistic replace w 0 l by something that draws a snake of the same length \documentclass{article} \...
David Carlisle's user avatar
23 votes

Typesetting curiosity: word change on one line does not affect how that line is set, but affects how the next line is set

As an addition to existing answers, the idea is as follows. TeX classifies lines in a paragraph as tight decent loose very loose overfull/underfull according to their badness, which is computed by ...
egreg's user avatar
  • 1.1m
22 votes

Best practices for source file line lengths?

I'll use an example from the TeXBook source This manual is intended for people who have never used \TeX\ before, as well as for experienced \TeX\ hackers. In other words, it's supposed to be a ...
David Carlisle's user avatar
21 votes

Allowing line break at ',' in inline math mode?

Here is a solution that doesn't make the comma globally active: \documentclass{article} \newcommand{\splitatcommas}[1]{% \begingroup \begingroup\lccode`~=`, \lowercase{\endgroup \edef~{\...
egreg's user avatar
  • 1.1m
21 votes
Accepted

Multi-line legend entry in pgfplots

By default, TikZ nodes do not allow line breaks, but if you add the align=<left/right/center> key you can use \\. Hence, you can modify the legend style as below. \documentclass[border=4pt]{...
Torbjørn T.'s user avatar
21 votes

How to create nonbreaking arbitrary length snakes for full-width justification?

The snake could be improved. Also I never know how to do calculations with tikz coordinates, so I use zref instead. Edit Actually I think that my first example didn't work in all cases as the begin ...
Ulrike Fischer's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible