46

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}
5
  • 12
    You have captured the letter of the law regarding endline %'s, but unfortunately missed the spirit.
    – Ryan Reich
    May 16, 2013 at 0:38
  • 2
    @RyanReich You should explain in more details for new users, instead of just pointing it out.
    – Paradox
    Feb 26, 2018 at 0: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, 2018 at 2: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, 2018 at 0: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, 2018 at 21:01

1 Answer 1

81

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.

2
  • 21
    No space between \end and \begin, why didn't any one else mention that... Oct 22, 2014 at 8:26
  • 12
    The space always gets me. Latex shouldn't be that way. May 5, 2017 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.