4

When using minipage environments, as below, the left corner of the two environments are automatically placed at the same height in the document.

minipage example

\begin{minipage}{8em}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{minipage} 
\begin{minipage}{8em}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{minipage} 

When instead using two adjustwidth environments, specifying their margins instead of ther heights, the two text areas are not placed on the same horisontal line, but below eachother:

adjustwidth example

It is of course possible to "manually" how much to move the text area to the right upwards as below, but then the vertical space, -14.8em, need to be calculated manually for every inserted text. Is there any way to do this calculation automatically, such that will work independently of the length of the text inside the adjustwidth environments?

\begin{adjustwidth}{0em}{\dimexpr \textwidth - 8em}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{adjustwidth}%
\vspace{-14.8em}
\begin{adjustwidth}{8em}{\dimexpr \textwidth - 16em}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{adjustwidth}

The actual code I am trying to make work is pasted below.

\documentclass{article}


\usepackage{changepage}

\newcommand{\twocolumnsMinipage}[5]
{
\begin{minipage}{#1}
#4
\end{minipage} 
\hspace{#3}
\begin{minipage}{#2}
#5
\end{minipage} 
}

\newcommand{\twocolumnsAdjustwidth}[5]
{
\begin{adjustwidth}{0em}{\dimexpr \textwidth - #1}#4\end{adjustwidth}%
\vspace{-14.8em} % This calculation needs to be done automatically if this is to work for any text, since 15em is just what works for the texts I've used to test with
\begin{adjustwidth}{\dimexpr#1+#3}{\dimexpr \textwidth - #1-#2-#3}
#4
\end{adjustwidth}
}


\begin{document}

\noindent \twocolumnsMinipage{8em}{8em}{1em}
{Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. }
{Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. }



\twocolumnsAdjustwidth{8em}{8em}{1em}
{Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. }
{Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. }


\end{document}
  • Why not box them the same as with a minipage? – Werner Jun 23 '13 at 16:04
  • Because a minipage cannot span over several pages :) – malin Jun 23 '13 at 16:11
  • Sure. So how many lines of text are you planning on placing side-by-side? Just a single line, or multiple lines? If multiple lines, what about using multicol? – Werner Jun 23 '13 at 16:14
  • 1
    Please make your example into a complete document that shows the problem and all packages used. (I can't even guess the definition of adjustwith that you are using) – David Carlisle Jun 23 '13 at 16:40
  • It's unclear what you want to achieve. If the left text contains material that spans more than one line, the right text will appear aligned to the bottom line (or in the second page if the left text spans two pages and it would be impossible to bring it up. If the "left text" is just a label for the "right text", you're using the wrong approach. – egreg Jun 23 '13 at 16:40
2

This is the purpose of the paracol package. The text of a leftcolumn carries over to the left column on the next page, and likewise for the rightcolumn.

It still balks if you give it too much at once (like \lipsum[1-50]), and there are some issues with line-breaking, which may be solvable from within the package options.

EDIT

I edited the example to show one way of adjusting the column widths using the packages \setcolumnwidth command. This is dependent on the \textwidth, which I have set here using geometry, but you could try adjustwidth or other methods.

This is described on pp. 16--17 of the paracol manual, though unfortunately the documentation requires knowledge of discrete mathematics and provides no clear examples of usage! (Note to package author!)

As far as I can tell, the three numbers after \setcolumnwidth are the desired minimum spacing for the left column, the column separation, and the right column, respectively. The actual widths are calculated to fill the maximum space inside the textwidth.

This may not be the complete solution, but I think it points a way forward for how you might customize paracol.

\documentclass{article}
\usepackage{paracol, lipsum}
\usepackage[textwidth=201pt]{geometry}

\begin{document}

\setcolumnwidth{50pt/20pt, 50pt}

\begin{paracol}{2}
  \begin{leftcolumn}
  \lipsum[1-5]  
  \end{leftcolumn}
      \begin{rightcolumn}
      \lipsum[6-10]
      \end{rightcolumn}
\end{paracol}

\end{document}
  • I tried more or less all column-environments I could find at the time. However the main problem with the other ones, say paracol; was that it did not allow me to adjust the width of the columns of text. The only environment I actually wanted to use was therefor the adjustpage environment, so a suggestion on using another environment which no not make the same thing is not really helpful.. :( – malin Aug 19 '14 at 5:04
  • Please see my edit to the answer, which points toward how you might adjust the column widths. – musarithmia Aug 19 '14 at 12:02
0

I found a solution which works if no column needs more than one page (i.e. it is not a solution at all);

result

\documentclass{article}


\usepackage{changepage}
\usepackage{tikz}
\usepackage{calc}
\usetikzlibrary{tikzmark}


\newcommand{\twocolumnsMinipage}[5]
{
\begin{minipage}{#1}
#4
\end{minipage} 
\hspace{#3}
\begin{minipage}{#2}
#5
\end{minipage} 
}



\makeatletter
\newcommand{\gettikzxy}[3]{%
  \tikz@scan@one@point\pgfutil@firstofone#1\relax
  \edef#2{\the\pgf@x}%
  \edef#3{\the\pgf@y}%
}


\newcommand{\twocolumnsAdjustwidth}[5]
{%
\noindent\tikzmark{@anchor}%
%
\begin{adjustwidth}{0em}{\dimexpr \textwidth - #1}#4\end{adjustwidth}%
\begin{tikzpicture}[remember picture] 
\gettikzxy{(pic cs:@anchor)}{\Lx}{\Ly}
\global\edef\@y{\Ly}
\end{tikzpicture}
\vspace{-\@y}
\begin{adjustwidth}{\dimexpr#1+#3}{\dimexpr \textwidth - #1-#2-#3}
#4
\end{adjustwidth}
}


\makeatother



\begin{document}

\noindent \twocolumnsMinipage{8em}{8em}{1em}
{Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. }
{Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. }



\twocolumnsAdjustwidth{8em}{8em}{2em}
{Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. }
{Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. }


\end{document}
  • does this play well with the page breaks? – user4686 Jun 24 '13 at 6:50
  • No :( But I guess that would be easier to fix than the initial problem :S – malin Jun 24 '13 at 6:54
  • I you don't have to worry about page breaks the initial problem can be treated using minipages (or even parboxes). (I think) – user4686 Jun 24 '13 at 6:57
  • Its exactly the pagebreaks I want, and I seem to want to avoid using the usual column environments since most of these seem to mess up the space around figures/tables/equations – malin Jun 24 '13 at 8:03
  • Have you checked the parcolumns package? I just tried it out with the Lorem ipsum ... text repeated in three columns, the first one of 8em, the second one of 12em and the third one to fill the remaining width, and it worked nicely at a pagebreak. However I had to set the \parindent to 0pt. But this was my first use and I have barely read its documentation. – user4686 Jun 24 '13 at 8:26

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.