문서의 일부를 렌더링하지 않는 방법(순수 LaTeX)

문서의 일부를 렌더링하지 않는 방법(순수 LaTeX)

나는 큰 LaTeX 파일을 가지고 있고 그 내용의 대부분을 PDF에서 숨기고 싶지만 정리의 원래 번호 매기기 등은 유지하고 싶습니다. display:noneCSS와 비슷한 것입니다.

환경 comment은 콘텐츠를 전혀 처리하지 않기 때문에 도움이 되지 않습니다. 정리 외부의 텍스트를 숨기는 데에만 사용할 수 있습니다.

\hphantom또는 .\vphantom\begin{theorem}

더 정확하게 말하면 다음과 같은 것이 있다고 가정합니다.

% I want to hide from here ...
\section{Section 1}
\subsection{Subsection 1.1}
\begin{theorem}
First
\end{theorem}
% ... to here
\begin{theorem}
Second
\end{theorem}

PDF의 원래 번호가 있는 두 번째 정리만 보고 싶습니다 Theorem 1.1.2.

내 질문은 다음과 매우 유사합니다.이 하나, 그러나 해당 질문의 작성자는 Sage와 함께 작업하며 내가 이해하는 한 허용되는 답변은 Sage에만 해당됩니다.

이 효과를 얻을 수 있는 일반적인 방법이 없다면 다음 개체를 숨길 수 있는 방법이 있으면 좋겠습니다.

  • 섹션/하위 섹션 제목
  • 정리/정리 등
  • 피규어

또한 출력을 다른 파일(PDF가 아닌)로 "리디렉션"하는 방법도 고려했지만 해결책을 찾을 수 없었습니다.

마지막 대안은 다음과 같습니다.정리의 수를 "하드코드", 하지만 나는 그것을 피하고 싶습니다.

답변1

제외하려는 모든 항목이 명령 인수 내에 있거나 환경에 포함되어 있는 경우 작동할 수 있는 시도입니다. 그리고 제외하고 싶은 것이 무엇인지 정확히 알고 있다면.

왼쪽 이미지는 숨김이 없는 이미지이고, 오른쪽 이미지는 숨김이 있는 이미지입니다.

여기에 이미지 설명을 입력하세요 여기에 이미지 설명을 입력하세요

아이디어는 인수의 내용을 삼키면서도 여전히 카운터 연산을 수행하도록 모든 명령과 환경을 재정의하는 것입니다.

\documentclass{article}
\usepackage{environ}
\newtheorem{theorem}{Theorem}
\newenvironment{hide}%
  {\renewcommand\section[1]{\refstepcounter{section}}%
   \renewcommand\subsection[1]{\refstepcounter{subsection}}%
   \RenewEnviron{theorem}{\refstepcounter{theorem}}%
  }%
  {}
\begin{document}
% i want to hide from here ...
\begin{hide}
\section{Section 1}
\subsection{Subsection 1.1}
\begin{theorem}
First
\end{theorem}
\end{hide}
% ... to here
\begin{theorem}
Second
\end{theorem}
\subsection{Subsection 1.2}
\section{Section 2}
\begin{theorem}
Third
\end{theorem}
\end{document}

답변2

이 문서를 실행한 다음 includeonly의 주석 처리를 해제하고 다시 실행하면 2페이지에 정리 2가 포함된 단일 페이지 문서가 생성됩니다.

여기에 이미지 설명을 입력하세요

\begin{filecontents}{zzzz1.tex}
\section{Section 1}
\subsection{Subsection 1.1}
\begin{theorem}
First
\end{theorem}

\end{filecontents}
\begin{filecontents}{zzzz2.tex}
\begin{theorem}
Second
\end{theorem}
\end{filecontents}

\documentclass{article}
\newtheorem{theorem}{Theorem}

%\includeonly{zzzz2}

\begin{document}
% i want to hide from here ...
\include{zzzz1}
% ... to here
\include{zzzz2}
\end{document}

답변3

나는 gernot의 답변을 좋아하지만 그의 답변을 보기 전에 이미 이에 대해 시작했으므로 게시하는 것이 좋습니다.

\documentclass{article}
\newif\ifskipstuff

\skipstufffalse
%\skipstufftrue

\usepackage{amsmath}
\begin{document}

\ifskipstuff
    \refstepcounter{section}
    \refstepcounter{subsection}
    \refstepcounter{equation}
\else
    \section{Section 1}
    \subsection{Subsection 1.1}
    \begin{equation}
        First
    \end{equation}
\fi

\section{A Section}
\subsection{Subsection}
\begin{equation}
    Second
\end{equation}

\end{document}

단점은 항상 모든 카운터를 수동으로 늘려야 한다는 것입니다. 그다지 좋지는 않습니다(특히 조항에 많은 항목이 있는 경우 \else. 아마도 더 구체화될 수 있습니다(재정의된 환경 내에 검사를 포함하여 \ifskipstuff자체 검사를 수행할 수도 있음). 장점은 전역적으로 설정할 수 있다는 것입니다. 자료를 포함할지 여부를 각각 \skipstufffalse및 사이에서 변경 \skipstufftrue하면 사용 사례에 따라 장점이 될 수 있습니다.

\skipstufftrue:

건너뛰기사실

\skipstufffalse:

건너뛰기false

관련 정보