wspr / herries-press

A collection of LaTeX packages by Peter Wilson
http://wspr.github.com/herries-press/
30 stars 5 forks source link

Problem with changepage and parcolumns #9

Closed DavidSzwer closed 14 years ago

DavidSzwer commented 14 years ago

I am trying to use the "parcolumns" environment (from the package of the same name) inside an "adjustwidth" environment. The LaTeX compiles and produces output, but also throws the following error:

! LaTeX Error: Something's wrong--perhaps a missing \item.

The columns are produced correctly, but only one of the side margins is changed by adjustwidth. Here is an example:


\documentclass{article}

\usepackage{parcolumns}
\usepackage{changepage}

\begin{document}

\begin{adjustwidth}{2em}{2em}
    \begin{parcolumns}{2}
        \colchunk {
            Here a chunk...
        }   
        \colchunk {
            ...there a chunk
        }   
        \colplacechunks
    \end{parcolumns}
\end{adjustwidth}

\end{document}

Either environment on its own seems to work fine. I had the same problem using the "changemargin" environment defined at http://www.tex.ac.uk/cgi-bin/texfaq2html?label=chngmargonfly , and also when I used the "parallel" package instead of parcolumns.

My LaTeX version is "This is pdfTeX, Version 3.1415926-1.40.9 (MiKTeX 2.7) (preloaded format=latex 2009.11.13)" (from the .log file) on Windows XP.

Context: - I want a small length (perhaps half a page to one page) of two-column text/maths in the middle of standard, single-column text/maths. This is for a derivation where I handle two cases in parallel, applying the same operations to each (so using parcolumns to line up equivalent paragraphs is ideal). Using parcolumns alone makes those columns a bit too narrow for my equations, and making the whole document wider would probably make the single-column parts too wide. I don't want to start a new page when I change the number of columns.

I can work around this by making the text smaller instead of making the margins wider, but clearly using adjustwidth would be a more elegant and readable solution. Perhaps these environments are fundamentally incompatible?

Thank you very much for your time, and for a package that I'm bound to find useful in other situations :-)

David.

PS. "adjustwidth" does seem to work fine with the "multicols" environment from the "multicol" package.

wspr commented 14 years ago

Sorry for the slow reply. I'm afraid this problem is caused by parcolumns and the way that it interacts with list environments; you'll also notice that even after the compilation occurs, the left margin of the parcolumns is incorrect even though adjustwidth attempted to change it.

To get the example compiling without the error, you can write in the preamble

\makeatletter
\g@addto@macro\endparcolumns{\global\@newlistfalse}
\makeatother

but as mentioned above the output will be wrong unless you only want to adjust the RHS margin.

Alternatively, you can also work around the problem by putting everything inside a minipage:

\begin{adjustwidth}{-5em}{5em}
\begin{minipage}{\linewidth}
  \begin{parcolumns}{2}
        \colchunk {\lipsum[8]}   
        \colchunk {\lipsum[9]}   
        \colplacechunks
        \colchunk {\lipsum[5]}   
        \colchunk {\lipsum[11]}   
        \colplacechunks
  \end{parcolumns}
  \end{minipage}
\end{adjustwidth}

(using the lipsum package) but in this case you then cannot break the text over pages, which is arguably even worse than the restriction above.

Sorry for the bad news; I'm afraid that there's nothing to be done, to the best of my knowledge. I suggest petitioning the author of parcolumns to add margin-adustment to his package, where it would be possible to some degree. (Since he has control over where the text chunks get placed on the page.)

DavidSzwer commented 14 years ago

Thank you,

In the end, using multicols was a good enough work-around for me, but it's good to know that the problem is fundamental to parcolumns rather than a bug at my end. Those hints will be useful for the future, though.

Best regards,

David.