1

I am trying to split a page into 2 halfs, using 2 minipages side by side. So I made the following construct

\begin{multicols}{2}
\begin{minipage}[t]{0.45\textwidth}
  stuff here
\end{minipage}
%
\begin{minipage}[t]{0.45\textwidth}
  stuff here
\end{minipage}
\end{multicols}

Which seems to work very well, except I noticed inside a section I had to reduce the 0.45 value to keep the 2 minipages next to each others. So I am wondering why as I had thought \textwidth remains the same.

Here is an example which works, when outside a section

\documentclass[12pt]{book}% 
\usepackage[margin=1in]{geometry}
\usepackage{multicol}
\begin{document}
\begin{multicols}{2}
\begin{minipage}[t]{0.45\textwidth}
  xxxxxxxxxxx
\end{minipage}
%
\begin{minipage}[t]{0.45\textwidth}
  xxxxxxxxxxx
\end{minipage}
\end{multicols}
\end{document}

Mathematica graphics

Now I simply add a section, and kept everything the same, and it still works, as long as there is nothing before the cols

\documentclass[12pt]{book}%               
\usepackage[margin=1in]{geometry}
\usepackage{multicol}
\begin{document}    
\section{foo}
\begin{multicols}{2}
\begin{minipage}[t]{0.45\textwidth}
  xxxxxxxxxxx
\end{minipage}
%
\begin{minipage}[t]{0.45\textwidth}
  xxxxxxxxxxx
\end{minipage}
\end{multicols}
\end{document}

Mathematica graphics

I added one single letter before the 2 columns, and now the minipages are on top of each others

\documentclass[12pt]{book}%               
\usepackage[margin=1in]{geometry}
\usepackage{multicol}
\begin{document}

\section{foo}
z

\begin{multicols}{2}
\begin{minipage}[t]{0.45\textwidth}
  xxxxxxxxxxx
\end{minipage}
%
\begin{minipage}[t]{0.45\textwidth}
  xxxxxxxxxxx
\end{minipage}
\end{multicols}
\end{document}

Mathematica graphics

When I reduced the size of minipage from 0.45 to 0.4 then it worked again

\documentclass[12pt]{book}%               
\usepackage[margin=1in]{geometry}
\usepackage{multicol}
\setlength\parindent{0pt}
\begin{document}
\section{foo}
z

\begin{multicols}{2}
\begin{minipage}[t]{0.40\textwidth}
   xxxxxxxxxxx
\end{minipage}
%
\begin{minipage}[t]{0.40\textwidth}
    xxxxxxxxxxx
\end{minipage}
\end{multicols}
\end{document}

Mathematica graphics

Question is: Why I had to reduce the size on minipage inside section to keep them side by side when adding a line before? does text width change depending on being in chapter, section, etc...?

Appendix:

I did try \setlength\parindent{0pt} thinking it was an indent thing, but it had no effect

\documentclass[12pt]{book}%               
\usepackage[margin=1in]{geometry}
\usepackage{multicol}
\setlength\parindent{0pt}
\begin{document}

\section{foo}
z

\begin{multicols}{2}
\begin{minipage}[t]{0.45\textwidth}
   xxxxxxxxxxx
\end{minipage}
%
\begin{minipage}[t]{0.45\textwidth}
    xxxxxxxxxxx
\end{minipage}
\end{multicols}
\end{document}

Mathematica graphics

I do not know why \noindent worked in the answer given below, but a global \setlength\parindent{0pt} did not!

  • Remove the space between the minipages. Though that isn't why. – cfr May 26 '16 at 0:40
  • @cfr I have space between them? I made sure to put % just to clear extra clear there is no space. hum... I will run a HEX dump program in source code to check for a white space between, since I do not see it in the editor now. Thanks. – Nasser May 26 '16 at 0:43
  • 1
    There's a space at \end{minipage} because you haven't commented the line ending. The comment on the next line doesn't obliterate the space you just input. I can get the minipages to go on top of each other using multicols but I cannot get a difference depending on whether there is content before them, with or without \parindent at zero and with or without the interword space between the minipages. Either both cases are side-by-side or both are staked. – cfr May 26 '16 at 0:52
  • 1
    @DavidCarlisle Well, with default \columnsep and the \textwidth in the example, there is more than sufficient space. It isn't just luck if you know this from experience. – cfr May 26 '16 at 0:53
  • 1
    no it's just wrong, just use a single row two column table. – David Carlisle May 26 '16 at 1:10
4

By default, \section suppresses the indentation of the first paragraph, so

\section{foo}
\begin{multicols}{2}
\begin{minipage}[t]{0.45\textwidth}
  xxxxxxxxxxx
\end{minipage}

starts the first minipage at the left margin.

When you add content before the columns

\section{foo}
z

paragraph indentation is suppressed before that content. Then there's a paragraph break, so

\begin{multicols}{2}
\begin{minipage}[t]{0.45\textwidth}
   xxxxxxxxxxx
\end{minipage}

the first minipage is indented as normal.

In your final example, you don't just change the width, you also zero the default paragraph indentation. But you don't need to - and almost certainly should not - do this. You can simply use \noindent.

\section{foo}
z

\noindent
\begin{multicols}{2}
  \begin{minipage}[t]{0.45\textwidth}
    xxxxxxxxxxx
  \end{minipage}
  %
  \begin{minipage}[t]{0.45\textwidth}
    xxxxxxxxxxx
  \end{minipage}
\end{multicols}

kill indentation

But the multicols environment is really not needed here. You can just use minipages:

\section{bar}
a

\noindent
\begin{minipage}[t]{0.45\textwidth}
  yyyyyyyyyyy
\end{minipage}%
\hfill
\begin{minipage}[t]{0.45\textwidth}
  yyyyyyyyyyy
\end{minipage}

kill indentation with minipages alone

or

\section{foobar}
b

\noindent
\hfill
\begin{minipage}[t]{0.45\textwidth}
  zzzzzzzzzzz
\end{minipage}%
\hfill
\begin{minipage}[t]{0.45\textwidth}
  zzzzzzzzzzz
\end{minipage}%
\hspace*{\fill}

variant minipage spacing

For comparison:

comparison

\documentclass[12pt]{book}
\usepackage[margin=1in]{geometry}
\usepackage{multicol}
\begin{document}
\section{foo}
z

\noindent
\begin{multicols}{2}
  \begin{minipage}[t]{0.45\textwidth}
    xxxxxxxxxxx
  \end{minipage}
  %
  \begin{minipage}[t]{0.45\textwidth}
    xxxxxxxxxxx
  \end{minipage}
\end{multicols}

\section{bar}
a

\noindent
\begin{minipage}[t]{0.45\textwidth}
  yyyyyyyyyyy
\end{minipage}%
\hfill
\begin{minipage}[t]{0.45\textwidth}
  yyyyyyyyyyy
\end{minipage}

\section{foobar}
b

\noindent
\hfill
\begin{minipage}[t]{0.45\textwidth}
  zzzzzzzzzzz
\end{minipage}%
\hfill
\begin{minipage}[t]{0.45\textwidth}
  zzzzzzzzzzz
\end{minipage}%
\hspace*{\fill}


\end{document}
  • Thanks for the answer, but I did try \setlength\parindent{0pt} and it had no effect! I did not show this attempt to keep the question short. I can post the example now as appendix. That is why I was confused. It must be as you way \section suppresses the indentation of the first paragraph, which I did not know about. (so may rules to remember). – Nasser May 26 '16 at 0:14
  • @Nasser Works fine for me if I remove the \noindents and set \parindent to zero. – cfr May 26 '16 at 0:18
  • Please see example I just posted. I – Nasser May 26 '16 at 0:19

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.