4

I want to layout a LaTeX document with following conditions:

  • Let the base element of my document be a box.
  • A box contains a content which must not be split by page breaks, and in a multi columned environment, it should not be split by a column break.
  • The width of a box will be defined before. The height of the box may vary. The boxes should work fine with \vspace macro, because the boxes may contain additional space after or before its real content.
  • The boxes must lay on a multi columned page. Each column must contain maximum number of boxes.
  • If the total height of boxes in a column, does not fill the whole column vertically, the rest space must be shared between boxes vertically.

To be more clear, I have made some drawings describing what I want: Hand drawing describing what I want

Sorry for hand drawing I had not enough time to make it using computer. So can you provide me sample code for making this layout?

  • Perhaps it would be easier to understand if you shared shy you're going for this layout. Abstracted definitions are important, but it's not really what people can usually work with intuitively. – Sean Allred Jan 21 '15 at 20:29
  • I want to make a test. I am going to use this layout for aligning questions. I have asked about this before, but the answers weren't enough for me. So I decided to define it more clear. – jnbrq -Canberk Sönmez Jan 21 '15 at 20:34

1 Answers1

6

If I understand your requirements correctly, you can achieve your objectives by using minipage environments -- one of the main features of a minipage is that it will never be broken across columns or pages. The code below defines a new environment, called mybox, that acts as a front-end for LaTeX's minipage environment.

In the example below, the minipages are filled with filler text; you're of course free to fill it with anything else.

enter image description here

\documentclass[twocolumn]{article}
\raggedbottom
\newcommand\myskip{\vspace{0.75cm}}  % vertical spacing between mybox environments
\newenvironment{mybox}{\par\noindent%
   \begin{minipage}{\linewidth}}
   {\end{minipage}\par\myskip}
\usepackage{lipsum}  % filler text

\begin{document}
\begin{mybox}
\lipsum[1]
\end{mybox}

\begin{mybox}
\lipsum[2]
\end{mybox}

\begin{mybox}
\lipsum[3]
\end{mybox}

\begin{mybox}
\lipsum[4]
\end{mybox}

\begin{mybox}
\lipsum[5]
\end{mybox}

\begin{mybox}
\lipsum[6]
\end{mybox}

\end{document}
Mico
  • 506,678
  • Wouldn't a fill type \myskip be more to the OP's scheme than a fixed \vspace? – Steven B. Segletes Jan 21 '15 at 23:15
  • That's looking great! But I want to share the space vertically between boxes equally. I do not want fixed size spaces. Spaces must be calculated automatically. – jnbrq -Canberk Sönmez Jan 22 '15 at 05:37
  • 1
    @jnbrq - I actually considered using \vspace{\fill} instead of \vspace{<some fixed length>} in the argument of the \myskip macro to create the gaps between the boxes. The problem with letting the heights be determined automatically by LaTeX is that one can get wildly different heights across columns. In good typography, the "negative spaces" (e.g., the blank spaces between boxes) matter every bit as much as do the "positive" spaces. If one lets the heights of the blank boxes vary across columns, one risks drawing much attention to them and create a distraction. What do you think? – Mico Jan 22 '15 at 06:50
  • Negative spaces don't matter very much. \vspace{\fill} worked very well. Thank you very much. :) – jnbrq -Canberk Sönmez Jan 22 '15 at 09:37
  • @jnbrq - Good to know that \vspace{\fill} works for you. :-) – Mico Jan 22 '15 at 10:00
  • @mico You may want to look at this question. Because it is related to your answer. http://tex.stackexchange.com/questions/224387/a-question-of-latex-layouting-using-vspace-fill-and-multi-columned-page – jnbrq -Canberk Sönmez Jan 22 '15 at 14:05