当我编译此代码时
\documentclass{article}
\usepackage{blindtext}
\usepackage{color}
\usepackage{picture}
\usepackage{atbegshi}
\AtBeginShipoutInit
\AtBeginShipout{%
\AtBeginShipoutUpperLeft{%
\put(0,-\paperheight){{\color{red}\box\AtBeginShipoutBox}}%
}%
}
\begin{document}
\blinddocument
\end{document}
我明白了(第 2 页)
问题:为什么标签是黑色的?
答案1
为了在列表中获得适当的对齐(特别是itemize
和enumerate
),LaTeX盒子物品标签。一旦物品装箱,它就固定了,你的\color
命令就无法到达它。
下面是使用临时框复制行为的最小示例\@tempboxa
:
\documentclass{article}
\usepackage{color,picture,atbegshi}
\AtBeginShipout{%
\AtBeginShipoutUpperLeft{%
\put(0,-\paperheight){{\color{red}\box\AtBeginShipoutBox}}%
}%
}
\begin{document}
\makeatletter
% Since this is boxed, it will remain black
\sbox\@tempboxa{this is some text}\usebox\@tempboxa
\makeatother
\begin{itemize}
\item First
\item Second
\item Last
\end{itemize}
\end{document}
答案2
如果你正在使用,pdflatex
你可以使用\pdfliteral
影响一切,因为颜色是在查看器中呈现的,而 TeX 对此并不了解。
\documentclass{article}
\usepackage{blindtext}
\usepackage{picture}
\usepackage{atbegshi}
\AtBeginShipoutInit
\AtBeginShipout{%
\AtBeginShipoutUpperLeft{%
\put(0,-\paperheight){%
% Color code: R G B
\pdfliteral direct{q 1 0 0 rg}%
\box\AtBeginShipoutBox%
\pdfliteral direct{Q}%
}%
}%
}
\begin{document}
\blinddocument
\end{document}