我正在尝试使用这个使用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}}
Run Code Online (Sandbox Code Playgroud)
哪个效果很好: 乳胶头http://img6.imageshack.us/img6/6757/screenshotewa.png
嗯,几乎,因为在当前章节"Lorem ipsum"的最后一页,它的行为就像我没有指示它:\ addtolength {\ headwidth} {\newtextwidth}: 在章节末尾的乳胶头http:/ /img11.imageshack.us/img11/6072/screenshotwbd.png
我怎么能解决这个问题?
编辑:
我也在使用fancyhdr.
第二编辑:
一个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}
Run Code Online (Sandbox Code Playgroud)
应该可以在"multi"之后在同一页面上继续单列,但是必须保持标题,就像在"多"环境中启动页面一样.
为什么我需要在具有marginpar的同一页面上的多列之后使用单列?想象一下,展示文章的源代码,边缘有一些小提示.(这就是上市包的用途)
我运行了你的测试文件.它似乎有一个\newlength{\newtextwidth}具有全局效果的错误,因此会导致错误.不知道为什么会这样,但我把它拉出来\newenvironment{multi}没有任何不良影响.
查理的诊断肯定是正确的.另一种解决方案是在多核之后但在调整宽度之前结束页面,因此:
\newenvironment{multi}[1]{%
...}
{\end{multicols}\vfill\break\end{adjustwidth}}
Run Code Online (Sandbox Code Playgroud)
我已经测试了这个解决方案,在您的示例文档中,它产生了良好的输出.
| 归档时间: |
|
| 查看次数: |
2097 次 |
| 最近记录: |