我有两段“代码”,单独使用时可以完美运行。第一段构建了 marginpar 表,第二段为 marginpar 环境提供了某些自定义设置。当我将两者复制到一个文档中时,它会生成 Marginpar 表,但无法正确应用自定义设置。
这是定制的(它不是我自己创建的。不幸的是,我不记得来源了):
\setlength{\marginparwidth}{1.2in} % Veränderung Marginpar
\let\oldmarginpar\marginpar
\renewcommand\marginpar[1]{\-\oldmarginpar[\raggedleft\footnotesize #1]%
{\raggedright\footnotesize #1}}
ToM 代码来自上一个问题(列出目录中的边距),由 henrique 提供:
\documentclass{article}
\usepackage{tocloft,blindtext}
\usepackage[english]{babel}
% First we create new list of marginpars with the help of tocloft package:
\newcommand{\listmarginparname}{List of Margin Pars}
\newlistof{marginpar}{lom}{\listmarginparname}
% Then we define a command that increments a counter and writes it in the created list
\newcommand{\mpar}[1]{%
\refstepcounter{marginpar}
\addcontentsline{lom}{marginpar}{#1}}
% Now we have to make \marginpar command to include the counting macro
\newcommand*\origmpar{}
\let\origmpar\marginpar
\renewcommand*\marginpar[1]{\origmpar{#1}\mpar{#1}}
\begin{document}
\listofmarginpar
\section{Two marginpars}
\blindtext \marginpar{First Marginpar Test}
\blindtext \marginpar{Second Marginpar Test}
\section{One marginpar}
\blindtext \marginpar{Third marginpar Test}
\end{document}
我的问题:有谁知道如何在不影响其他定制的情况下获得这种 Marginpar 表?
答案1
这应该是你想要的:
\documentclass{article}
\usepackage{tocloft,blindtext}
\usepackage[english]{babel}
% First we create new list of marginpars with the help of tocloft package:
\newcommand{\listmarginparname}{List of Margin Pars}
\newlistof{marginpar}{lom}{\listmarginparname}
% Then we define a command that increments a counter and writes it in the created list
\newcommand{\mpar}[1]{%
\refstepcounter{marginpar}
\addcontentsline{lom}{marginpar}{#1}}
% Now we have to make \marginpar command to include the counting macro
% ADDED BY LOCKSTEP: And some other modifications
\setlength{\marginparwidth}{1.2in} % Veränderung Marginpar
\newcommand*{\origmpar}{}
\let\origmpar\marginpar
\renewcommand*{\marginpar}[1]{%
\-\origmpar[\raggedleft\footnotesize #1]{\raggedright\footnotesize #1}%
\mpar{#1}%
}
\begin{document}
\listofmarginpar
\section{Two marginpars}
\blindtext \marginpar{First Marginpar Test}
\blindtext \marginpar{Second Marginpar Test}
\section{One marginpar}
\blindtext \marginpar{Third marginpar Test}
\end{document}