2

I am working on my thesis, but I came to a problem with unbreakable space in latex using tilde. It does an unbreakable space, but puts both words on previous line so the line is longer and at the end a black square appears. How can I command it to put the words on the next line.

I am using TexStudio and this header:

\documentclass[12pt,a4paper]{report}
\setlength\textwidth{145mm}
\setlength\textheight{247mm}
\setlength\oddsidemargin{15mm}
\setlength\evensidemargin{15mm}
\setlength\topmargin{0mm}
\setlength\headsep{0mm}
\setlength\headheight{0mm}

\let\openright=\clearpage

%% Generate PDF/A-2u
\usepackage[a-2u]{pdfx}

%% Character encoding: usually latin2, cp1250 or utf8:
\usepackage[utf8]{inputenc}

%% Prefer Latin Modern fonts
\usepackage{lmodern}

%% Further useful packages (included in most LaTeX distributions)
\usepackage{amsmath}        % extensions for typesetting of math
\usepackage{amsfonts}       % math fonts
\usepackage{amsthm}         % theorems, definitions, etc.
\usepackage{bbding}         % various symbols (squares, asterisks, scissors, ...)
\usepackage{bm}             % boldface symbols (\bm)
\usepackage{graphicx}       % embedding of pictures
\usepackage{fancyvrb}       % improved verbatim environment
\usepackage{natbib}         % citation style AUTHOR (YEAR), or AUTHOR [NUMBER]
\usepackage[nottoc]{tocbibind} % makes sure that bibliography and the lists
                % of figures/tables are included in the table
                % of contents
\usepackage{dcolumn}        % improved alignment of table columns
\usepackage{booktabs}       % improved horizontal lines in tables
\usepackage{paralist}       % improved enumerate and itemize
\usepackage[usenames]{xcolor}  % typesetting in color
\usepackage{acro}
\usepackage{listings}

enter image description here

EDIT: The problem still remains even without the tilde.

enter image description here

4
  • 1
    Welcome to TeX.SX! You can use an explicit \\ or you may reword a bit, but to be honest the best thing to do is to let LaTeX do its justification work, because breaking before these two words will look horrible.
    – TeXnician
    Commented Jun 1, 2018 at 16:43
  • 2
    There's nothing bad with splitting a line after “the”.
    – egreg
    Commented Jun 1, 2018 at 16:58
  • 1
    please provide a sample document that shows the problem, not screenshots of the output. note that the - in Middle-European prevents hyphenation you could use Middle-\hspace{0pt}European Commented Jun 1, 2018 at 17:57
  • I have the same problem. Neither the above comments nor the provided answer address a decent solution. Is there any real solution? I mean sometimes the line can be stretched and the letter after tilde can be pushed to next line. Or Latex might reduce the space between letters and make the whole line the same width as other lines. But this should be done "automatically". This was the idea of Latex though.
    – Alisa
    Commented Jun 9, 2018 at 20:48

1 Answer 1

1

You should use non-breaking spaces when needed. See When should I use non-breaking space?

The reason that you get an overlong line is not entirely due to the non-breaking space. To oversimplify things, you see, TeX tries its best to justify the text, firstly by stretching or shrinking the inter-word spaces within a line. If that is not good enough, it will try to hyphenate words at the end of lines.

And if that is still not enough, you will get an underfull hbox where the stretching is way too much, or an overfull hbox where text stick out beyond the margin.

If you are using pdfTeX or pdfLaTeX to compile your file, the best practice is to use the microtype package:

% Preamble
\usepackage{microtype}  % https://ctan.org/pkg/microtype

Check Microtype - Thesis in LaTeX for a display of how powerful microtype is.

Another solution is simply to rewrite your sentences until bad spots go away.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .