Title Width on the last page of a chapter

I am trying to disable marginpar when starting a new multi-tiered environment with this new environment that uses multicols and chngpage packages:

\newenvironment{multi}[1]{% \newlength{\newtextwidth}% \setlength{\newtextwidth}{\marginparwidth}% \addtolength{\newtextwidth}{-1cm}% \addtolength{\headheight}{.5cm}% \let\oldheadrule\headrule% \addtolength{\headwidth}{\newtextwidth}% \begin{adjustwidth}{}{-\newtextwidth}\begin{multicols}{#1}}% {\end{multicols}\end{adjustwidth}} 

What works great: latex header http://img6.imageshack.us/img6/6757/screenshotewa.png

Uhm, almost, since on the last page of the current chapter of "Lorem ipsum" it behaves as if I did not instruct it: \ addtolength {\ headwidth} {\ newtextwidth}: latex heading at the end of the chapter http: //img11.imageshack .us / img11 / 6072 / screenshotwbd.png

How can i fix this?

Edit

I also use fancyhdr.

2nd Edit :

A PoC:

 \documentclass[12pt,a4paper,oneside]{report} \usepackage[utf8]{inputenc} \usepackage[top=2cm,left=2cm,right=4.5cm]{geometry} \usepackage{chngpage} \usepackage{color} \usepackage{amsmath} \usepackage[pdftex,bookmarks,pdfpagemode=UseOutlines,bookmarksopen,backref ,colorlinks,urlcolor=blue,linktocpage]{hyperref} \usepackage{url} \usepackage{amssymb} \usepackage{lipsum} \usepackage{fancyhdr} \usepackage{multicol} \usepackage{indentfirst} \usepackage{listings} \usepackage{boxedminipage} \pagestyle{fancy} \setlength{\columnseprule}{1pt} \setlength{\marginparwidth}{4cm} \rhead{\large\leftmark} \renewcommand{\chaptermark}[1]{% \markboth{#1}{}} \makeatletter \renewcommand*\@makechapterhead[1]{% {\parindent \ z@ \raggedright \normalfont \huge\bfseries #1\par\nobreak \vskip 20\ p@ }} \makeatother \let\oldmarginpar\marginpar \renewcommand\marginpar[1]{\-\oldmarginpar[\sffamily\raggedleft\footnotesize #1]% {\sffamily\raggedright\footnotesize \begin{boxedminipage}{\marginparwidth}#1\end{boxedminipage} }} \newenvironment{multi}[1]{% \newlength{\newtextwidth}% \setlength{\newtextwidth}{\marginparwidth}% \addtolength{\newtextwidth}{-1cm}% \addtolength{\headheight}{.5cm}% \let\oldheadrule\headrule% \addtolength{\headwidth}{\newtextwidth}% \begin{adjustwidth}{}{-\newtextwidth}\begin{multicols}{#1}}% {\end{multicols}\end{adjustwidth}} \begin{document} \tableofcontents \chapter{Lorem ipsum} \begin{multi}{2} \lipsum[1-20] \end{multi} \chapter{Lorem ipsum} \begin{multi}{2} \lipsum[1-20] \end{multi} \chapter{Lorem ipsum} \begin{multi}{2} \lipsum[1-20] \end{multi} \end{document} 

It should be possible to continue the single-column page on the same page after "multi", but the headers should be stored as if the page was launched in the "multi" environment.

Why do I need one column after several columns on the same page with marginpar? Imagine the source code of an article, with a few tips in the margin. (This is what the listing package has)

+4
source share
2 answers

I suspect that your last headline lights up after the text finishes creating multi-tier boxes, so you are not within the scope of your changes. It is returning to its old meaning.

You should probably add the fancyhdr package and use it. I believe that he behaves well in a multi-column.

Good, so it's almost certainly a subject of scope. You are configuring in the new multi environment. When your text ends in several conditions, you have not completed the last page; headers are not configured until the page is full. Thus, your mutlti environment terminates the window, you leave the scope, and THEN the page terminates and is emitted. Using the old width.

Set the width and parameters of the header outside the environment.

+7
source

I ran a test document. It seems to have an error in that \newlength{\newtextwidth} has a global effect and therefore causes an error. I don’t know why this is so, but I pulled it out of \newenvironment{multi} without any harmful effect.

Charlie's diagnosis is definitely correct. An alternative solution is to complete the page after multicolors, but before adjusting, in this way:

 \newenvironment{multi}[1]{% ...} {\end{multicols}\vfill\break\end{adjustwidth}} 

I tested this solution and on your example document, it gives a good result.

+5
source

All Articles