54

In draft-mode a black marker indicates that the reserved space is too low. This also appears in the following example, but it shouldn't. How can I put two minipages exactly side-by-side?

\documentclass[draft=on]{scrbook}
\usepackage{blindtext}

\begin{document}
\begin{minipage}{.5\textwidth} %
  TEXT 1
\end{minipage} %
\begin{minipage}{.5\textwidth} %
  TEXT 2
\end{minipage}
\end{document}
Werner
  • 603,163
user4811
  • 4,185
  • 14
    You have captured the letter of the law regarding endline %'s, but unfortunately missed the spirit. – Ryan Reich May 16 '13 at 00:38
  • 2
    @RyanReich You should explain in more details for new users, instead of just pointing it out. – Paradox Feb 26 '18 at 00:14
  • 1
    @paradox I wish I remembered what I meant. Probably that if you're going to use % to remove line breaks, you should do so with code that is sensitive to them. – Ryan Reich Feb 26 '18 at 02:07
  • 1
    @RyanReich This is what I meant : lots of people (me included) know % removes lines breaks but only a few are able to point to a ressource where you can find use-cases where it's necessary. I think this kind of ressources could be helpful to broadcast. Because, like you pointed out, even you could not remember what you meant at the time you answered ;) – Paradox Mar 11 '18 at 00:19
  • @Paradox That's a reasonable point, but unfortunately, I have been completely out of touch with TeX programming for nearly four years, and I don't know if I could provide any references other than TeX By Topic, or of course The TeXbook, which is not online (but is worth buying). – Ryan Reich Mar 11 '18 at 21:01

1 Answers1

91

There are two problems in your input.

  1. A new paragraph is started with the first minipage, which adds the indent.
  2. There is a space between the two minipages.
\documentclass[draft=on]{scrbook}
\usepackage{blindtext}

\begin{document}
\noindent
\begin{minipage}{.5\textwidth}
  TEXT 1
\end{minipage}% This must go next to `\end{minipage}`
\begin{minipage}{.5\textwidth}
  TEXT 2
\end{minipage}
\end{document}

Note that

text %

has a space after "text", while

text%

hasn't. The % you're using in

\begin{minipage}{.5\textwidth} %

does nothing; the end-of-line or spaces after \begin{minipage}{...} are ignored anyway. So typing

\begin{minipage}{.5\textwidth} %

\begin{minipage}{.5\textwidth}%

\begin{minipage}{.5\textwidth}

is just the same.

egreg
  • 1,121,712