2

With the following code, TeX break lines after every two \myboxs, which is what I want.

\documentclass{article}

\RequirePackage[a3paper,landscape,twocolumn,columnsep=6cm,left=3cm,right=3cm]{geometry}
\usepackage{lipsum}

\setlength{\parindent}{0pt}
\newcommand{\mybox}[1]{\makebox[0.5\linewidth][l]{#1}\allowbreak\ignorespaces}

\begin{document}

\lipsum[2]
\mybox{AAAA}
\mybox{BBBB}
\mybox{CCCC}
\mybox{DDDD}

\lipsum[2]
\mybox{AAAA}
\mybox{BBBB}
\mybox{CCCC}
\mybox{DDDD}

\end{document}

enter image description here

Now I change geometry settings from

\RequirePackage[a3paper,landscape,twocolumn,columnsep=6cm,left=3cm,right=3cm]{geometry}

to the following line

\RequirePackage[a3paper,landscape,twocolumn,columnsep=4cm,left=5cm,right=3cm]{geometry}

Even if linewidth is the same, TeX changes its line breaking.

enter image description here

What is the problem with it? And how to improve \mybox command to get correct result with different columnsep?

1
  • In the second case, \linewidth is 27970197sp, but twice half the \linewidth is computed as 27970196sp. One scaled point can make the difference. You get an underfull \hbox also if you do \hbox to 2in{\hskip1in\hskip1in} for precisely the same 1sp difference.
    – egreg
    Jun 29, 2018 at 20:30

1 Answer 1

2

I think you are just being hit by rounding error,

\newcommand{\mybox}[1]{\makebox[0.5\linewidth][l]{#1}\allowbreak\hfill\ignorespaces}

works where the extra glue should be 0pt but....

You must log in to answer this question.

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