在使用 multicols 和 chngpage 包的这个新环境启动新的 multicols 环境时,我试图关闭 marginpar:
\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}}
哪个效果很好:
latex header http://img6.imageshack.us/img6/6757/screenshotewa.png
嗯,差不多,因为在当前章节“Lorem ipsum”的最后一页,它的行为就像我没有指示它:\addtolength{\headwidth}{\newtextwidth}:
latex header at the end of the chapter http://img11.imageshack.us/img11/6072/screenshotwbd.png
我怎么能解决这个问题?
编辑 :
我也在使用fancyhdr。
第二次编辑 :
概念验证:
\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}
在“多”之后,应该可以在同一页面上继续单列,但必须像在“多”环境中启动页面时一样保留标题。
为什么我需要在同一页上的多列之后使用边距为单列?想象一下展示文章的源代码,在页边空白处有小提示。 (这就是列表包的用途)
最佳答案
我怀疑你的最后一个标题框是在你的文本完成多列框之后构建的,所以你不在你的更改范围内。它返回到旧值。
您可能最好添加 fancyhdr 包并使用它。我相信它在多列中表现良好。
好的,所以这几乎可以肯定是范围的事情。您正在新的 multi
环境中执行 adjustwidth 。当你的文本在多环境下用完时,你还没有填满最后一页;在页面填满之前不会设置标题。所以你的 mutlti 环境完成了盒子,你离开了范围,然后页面完成并发出。使用旧的宽度。
在环境之外设置标题宽度和参数。
关于latex - 章节最后一页的页眉宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/829212/