1

I'we created such file:

\documentclass[a5paper]{report}
%\usepackage[showframe, margin=1cm]{geometry}

\usepackage[pdftex,colorlinks=true,allcolors=blue]{hyperref}

\begin{document}

    \paragraph{Aaaaaaaaaa bbbbbbbbbbbbbbbbbb ccccccccccccc dddddddddddddddd eeeeeeeeeeeeeeeee}

    Aaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbb ccccccccccccc ddddddddddddddd eeeeeeeeeeeeeeeee.

    \url{http://example.com/aaaaaaaaaaaaaaaaa_bbbbbbbbbb_cccccccccccccccc_ddddddddd_eeeeeeeee}

\end{document}

When I convert it to pdf with command pdflatex -synctex=1 -interaction=nonstopmode "latex-experimenting".tex (actually TeXstudio does that), I've got such a file:

Misformatted file

At first I supposed, that problem occurs only when I use package geometry, but I reproduced the problem without it.

I am not requiring those "fake words" to be hyphenated by parts, I would be satisfied, if they would just be moved to the next line, when needed.

What am I doing wrong?

  • 1
    Welcome to here. TeX just can't hyphenate words like 'ddddddddddddddd'. The lines will work if you use real words instead. For URLs, you need to tell hyperref to split them at additional points, probably. – cfr Oct 01 '19 at 23:31
  • \paragraph is for a sub-heading, by the way. – cfr Oct 01 '19 at 23:31
  • Hello, @cfr! When I comment usage of Geometry package, "word" "ccccccccccccc" is hyphenated! Actually, I don't actually need those words to be hyphenated. If they would be placed on the next line, it would be fine too. – Nickolay-Maryan Sokolovksy Oct 01 '19 at 23:54
  • That's because it apparently knows how to hyphenate 'ccccccccccccc'. If you replace the 'ddddddddddddddd' with another 'ccccccccccccc', it'll hyphenate it with geometry, too. geometry isn't doing anything relevant here. – cfr Oct 02 '19 at 00:27
  • I've edited my question -- as I figured out, problem with line breaks occurs without geometry package too. – Nickolay-Maryan Sokolovksy Oct 02 '19 at 00:34
  • 1
    \raggedright? Hard to see how else you can do this if your document really needs such non-words. – cfr Oct 02 '19 at 03:10
  • You can play around with the parameters \emergencystretch and \tolerance. They influence how paragraphs are broken into lines. Basically this is what the commands \sloppy and \fussy do: \sloppy increases \tolerance and \emergencystretch. \fussy resets LaTeX's default values for these parameters. (\hfuzz and \vfuzz get changed also but this does not affect the look of the resulting .pdf file. This affects when TeX will print error-messages due to boxes being taken for overfull.) This might be of interest. – Ulrich Diez Oct 02 '19 at 18:08

1 Answers1

2

You can play around with the parameters \emergencystretch and \tolerance. They influence how paragraphs are broken into lines.

Basically this is what the commands \sloppy and \fussy do:
\sloppy increases \tolerance and \emergencystretch.
\fussy resets LaTeX's default values for these parameters.
(\hfuzz and \vfuzz get changed also but this does not affect the look of the resulting .pdf file. This affects when TeX will print error-messages due to boxes being taken for overfull.)

These explanations by David Carlisle might be of interest.

\documentclass[a5paper]{report}
%\usepackage[showframe, margin=1cm]{geometry}

\usepackage[pdftex,colorlinks=true,allcolors=blue]{hyperref}

\makeatletter
\newcommand*\avoidhyphens{%
  \emergencystretch\hsize
  \tolerance 200%
  \hfuzz .1\p@
  \vfuzz\hfuzz
}%
\makeatother

\begin{document}
    \hrule height 0pt width 0pt depth 0pt
    \kern-1in
    \kern-\topmargin
    \kern-\headheight
    \kern-\headsep
    %\kern-\topskip
    \vfill\verb|\fussy| is default:\vfill

    % The sectionng command "\paragraph" creates a vertical gap of 3.25ex with report. Let's remove that:
    \kern-3.25ex
    \paragraph{Aaaaaaaaaa bbbbbbbbbbbbbbbbbb ccccccccccccc dddddddddddddddd eeeeeeeeeeeeeeeee}

    Aaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbb ccccccccccccc ddddddddddddddd eeeeeeeeeeeeeeeee.

    \url{http://example.com/aaaaaaaaaaaaaaaaa_bbbbbbbbbb_cccccccccccccccc_ddddddddd_eeeeeeeee}

    \vfill\verb|\avoidhyphens|:\vfill

    \avoidhyphens
    \kern-3.25ex
    \paragraph{Aaaaaaaaaa bbbbbbbbbbbbbbbbbb ccccccccccccc dddddddddddddddd eeeeeeeeeeeeeeeee}

    Aaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbb ccccccccccccc ddddddddddddddd eeeeeeeeeeeeeeeee.

    \url{http://example.com/aaaaaaaaaaaaaaaaa_bbbbbbbbbb_cccccccccccccccc_ddddddddd_eeeeeeeee}

    \vfill\verb|\sloppy|:\vfill

    \sloppy
    \kern-3.25ex
    \paragraph{Aaaaaaaaaa bbbbbbbbbbbbbbbbbb ccccccccccccc dddddddddddddddd eeeeeeeeeeeeeeeee}

    Aaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbb ccccccccccccc ddddddddddddddd eeeeeeeeeeeeeeeee.

    \url{http://example.com/aaaaaaaaaaaaaaaaa_bbbbbbbbbb_cccccccccccccccc_ddddddddd_eeeeeeeee}

    \vfill\verb|\fussy|:\vfill

    \fussy
    \kern-3.25ex
    \paragraph{Aaaaaaaaaa bbbbbbbbbbbbbbbbbb ccccccccccccc dddddddddddddddd eeeeeeeeeeeeeeeee}

    Aaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbb ccccccccccccc ddddddddddddddd eeeeeeeeeeeeeeeee.

    \url{http://example.com/aaaaaaaaaaaaaaaaa_bbbbbbbbbb_cccccccccccccccc_ddddddddd_eeeeeeeee}

    \vfill\verb|\raggedright|:\vfill

    \begingroup\raggedright
    \kern-3.25ex
    \paragraph{Aaaaaaaaaa bbbbbbbbbbbbbbbbbb ccccccccccccc dddddddddddddddd eeeeeeeeeeeeeeeee}

    Aaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbb ccccccccccccc ddddddddddddddd eeeeeeeeeeeeeeeee.

    \url{http://example.com/aaaaaaaaaaaaaaaaa_bbbbbbbbbb_cccccccccccccccc_ddddddddd_eeeeeeeee}

    \endgroup
    \vfill

\end{document}

enter image description here

Ulrich Diez
  • 28,770