Friday, May 6, 2011

Turning off marginpar (marginparwidth) while in multicols environment

I'm trying to turn off marginpar when starting a new multicols environment with this:

\renewenvironment{multicols}[1]{%
  \let\oldmarginparwidth\marginparwidth 
  \setlength{\marginparwidth}{0}%
  \begin{multicols}{#1}
}{%
  \end{multicols}%
  \setlength{\marginparwidth}{\oldmarginparwidth}%
}

However, it doesn't work. What am I missing?

From stackoverflow
  • I'm not sure exactly what you're looking for here, but generally marginpars aren't allowed in multicols already. From the multicol documentation:

    ...floats and marginpars are not allowed in the current implementation [This is dictated by lack of time. To implement floats one has to reimplement the whole LATEX output routine.].

  • I have managed to get it working by using the chngpage package and defining a new environment which sets/resets different values before/after that environment.

    However, I still have a problem on the last page of each \chapter: header width on the last page of the chapter

  • The command you've got there won't work mid-page, you need to use the changepage package to do that.

    \usepackage{changepage}
    

    I take it you're trying to take up the full width of the page. I nicked this from the tufte-latex class:

    First, define an 'overhang' amount that'll be added to the textwidth at the beginning and subtracted at the end:

    \newlength{\overhang}
    \setlength{\overhang}{\marginparwidth}
    \addtolength{\overhang}{\marginparsep}
    

    Then use \adjustwidth with the overhang amount when you want to remove marginpar space:

    \begin{adjustwidth}{}{-\overhang}
    % This will be displayed full-width
    \end{adjustwidth}{}{-\overhang}
    

    As Damien pointed out, you can still use marginpars like this, they'll just exceed the pagewidth. \multicols will prevent you from using floats, however.

    Hope that's what you need!

0 comments:

Post a Comment