2

I am writing a text using LaTeX. I want my test to be 2-columned. I have done this using multicols environment. My question's text and its choices mustn't be splitted by a page break, or column break. So I have used put my code inside \vbox. Now I want to align my questions automatically. The free space in each column must be shared equally between questions. So how can I achieve this?

Here is an example for what I tried:

\documentclass{article}
\usepackage{multicol}
\begin{document}
    \begin{multicols}{2}
        \noindent
        \vbox
        {
            Question content
        } \\
        \vbox
        {
            Question content
        } \\
        \vbox
        {
            Question content
        } \\
        \vbox
        {
            Question content
        } \\
        \vbox
        {
            Question content
        } \\
        \vbox
        {
            Question content
        }\\
    \end{multicols} 
\end{document}

As you will be able to see in output, spaces between \vbox s are not distributed equally, and looks ugly. Note: I mean vertical axis.

8
  • 2
    Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. In particular, it would be very helpful to know which documentclass you're using, because this may change the answers.
    – darthbith
    Commented Jan 15, 2015 at 16:01
  • Remove the \\ after the last question, or else it breaks it up as 4 Q on the left and 2Q+blank Q on the right. Commented Jan 15, 2015 at 20:20
  • I'm not sure I see what you're describing. Are you referring to vertical spaces or horizontal spaces? Here's what I see. Commented Jan 15, 2015 at 20:31
  • Vertical spaces. Commented Jan 15, 2015 at 20:43
  • i.sstatic.net/bMy2e.png This image describes what I want. Red boxes are questions. Gray space between questions must be shared equally in a column. The maximum number of red boxes must be inserted each column. Commented Jan 15, 2015 at 20:51

1 Answer 1

2

The use of \vboxes is inappropriate for what you are trying to achieve, that is balanced columns.

\vboxes and \parboxes or \minipages in TeX are containers with unbreakable content. It is better to use lists to format your text of questions.

The following minimal demonstrates the issue.

\documentclass{article}
\usepackage{lipsum,xcolor,calc}
\usepackage{multicol}
\def\story#1#2{%
 \leavevmode
   \colorbox{#1}{\parbox{\columnwidth-\columnsep}{#2}}%
  }
\parindent0pt
\begin{document}
    \begin{multicols}{2}

        \story{orange!50}{\lipsum[1]}

        Question content

        \fbox{\story{black!20}{\lipsum[7]}}   

       Question content


       \story{orange!30}{\lipsum[8]}

       Question content

       Question content

    \end{multicols} 
\end{document}

enter image description here

As the framed box cannot be fitted at the bottom of the column, LaTeX moves it to the right column, then when the columns are balanced, you get the ugly layout you have mentioned. Better post a new question with an example of what you are trying to achieve.

You must log in to answer this question.

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