我想有选择地打印文章的某些部分。
我想要的是隐藏“XX”之间的部分,而不改变其他任何东西。
我该怎么做?以下是我正在尝试的:
\documentclass[a4paper]{article}
\usepackage{environ}
\NewEnviron{myhideenv}{
%\ifshow
{\tiny {XX\BODY{}XX}}
%\fi
}
\begin{document}
The start of the report.
\begin{myhideenv}
\section{Testsection not printed} \label{testsection}
Test not printed
\end{myhideenv}
Section reference is still correct: \ref{testsection}
\section{This is section two}
It is still correct when myhideenv is hidden.
The end of the report.
\end{document}
Phantom(或变体)将不起作用,因为它们仍在为文本腾出空间。它不能是可选择的隐藏文本,即白色背景上的白色文本。
答案1
不是 100% 安全但是...
\documentclass[a4paper]{article}
\usepackage{environ}
\NewEnviron{myhideenv}{%
\setbox0\vbox{%
\let\xxwrite\write
\protected\def\write{\immediate\xxwrite}%
{\tiny XX\BODY XX}}
}
\begin{document}
The start of the report.
\begin{myhideenv}
\section{Testsection not printed} \label{testsection}
Test not printed
\end{myhideenv}
Section reference is still correct: \ref{testsection}
\section{This is section two}
It is still correct when myhideenv is hidden.
The end of the report.
\end{document}
保存在丢弃的框中并在本地重新定义,这样即使从未出现在页面上,\write
引用也会写入辅助文件。\label