
단순화하기 위해 텍스트와 정리만 포함된 문서가 있다고 가정하겠습니다.
정리에 포함된 텍스트만 표시하고 싶습니다. 예를 들어
\documentclass[10pt]{book}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{theorem}{Definition}
\begin{document}
\chapter{One}
\section{One}
blah
\section{Two}
\begin{theorem}
Blo
\end{theorem}
\chapter{Two}
Blih
\end{document}
나는 단지 다음을 표시하고 싶습니다: 1.하나 1.하나 2.두 정리:블로" 2.2
별도의 환경에서 텍스트를 동봉하지 않고도 가능할까요?
한 가지 해결책은 정리를 제외하고 글꼴 크기를 0으로 설정하는 것과 같은 몇 가지 트릭을 사용하여 정상적인 출력을 억제하는 것입니다(그렇게 할 수는 없었습니다).
감사해요
편집: 아마도 한 가지 방법은 기본 문서를 출력하지 않고 일부 패키지를 사용하여 정리의 모든 내용을 자동으로 수집하고 수집된 내용만 출력하는 것이지만 장 및 섹션 제목도 갖고 싶습니다...
답변1
OP는 "텍스트와 정리만 있는 문서가 있다고 가정해 보겠습니다"라고 규정합니다.
나는 결과를 얻기 위해 하나의 인스턴스가 전체 문서를 둘러싸는 tokencycle
가상 환경을 사용합니다.\shothms...\endshothms
\chapter
현재 편집되었으므로 & \section
(선택적 인수 없이) 및 theorem
& proposition
환경 의 인스턴스만 실행합니다 . 이러한 매크로/환경에 대한 선택적 인수는 를 통해 처리할 수 있지만 tokcycle
여기에는 시간과 코드를 투자하고 싶지 않았습니다. 보다포함된 매크로를 실행하는 동안 문자별로 인수 구문 분석, 예를 들어 완료되었습니다.
매크로 테스트(캡처할 추가 매크로를 추가하려는 경우)는 매크로에 의해 수행됩니다 \testmacros
.
\newcommand\testmacros[1]{%
\ifx\chapter#1\addcytoks{#1}\gdef\addarg{T}\else
\ifx\section#1\addcytoks{#1}\gdef\addarg{T}\else
\gdef\addarg{F}\fi\fi
}
환경 테스트(더 필요한 경우)는 \testenvs
다음과 같이 매크로에 의해 수행됩니다.
\newcommand\testenvs[1]{%
\ifx\thmchk#1 1\else
\ifx\propchk#1 1\else
0\fi\fi
}
주어진 서문 정의
\def\thmchk{theorem}
\def\propchk{proposition}
MWE:
\documentclass{book}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{tokcycle}
\def\addarg{F}
\def\checktheorems{F}
\def\charson{F}
\def\thmchk{theorem}
\def\propchk{proposition}
\declaretheorem{theorem}
\declaretheorem{proposition}
\stripgroupingtrue
\tokcycleenvironment\shothms
{\if T\charson\addcytoks{##1}\fi}
{%
\if T\addarg\addcytoks{{##1}}\gdef\addarg{F}\fi
\if F\checktheorems
\if T\charson\addcytoks{{##1}}\fi
\else
\gdef\tmp{##1}%
\ifnum\testenvs{\tmp}=1\relax
\if B\checktheorems
\addcytoks{\begin{##1}}\gdef\charson{T}%
\else
\addcytoks{\end{##1}}\gdef\charson{F}%
\fi
\fi%
\fi
\gdef\checktheorems{F}
}
{%
\ifx\begin##1\gdef\checktheorems{B}\else
\ifx\end##1\gdef\checktheorems{E}\else
\gdef\checktheorems{F}%
\if T\charson\addcytoks{##1}\fi%
\fi
\fi
\testmacros{##1}%
}
{\if T\charson\addcytoks{##1}\fi}
\newcommand\testmacros[1]{%
\ifx\chapter#1\addcytoks{#1}\gdef\addarg{T}\else
\ifx\section#1\addcytoks{#1}\gdef\addarg{T}\else
\gdef\addarg{F}\fi\fi
}
\newcommand\testenvs[1]{%
\ifx\thmchk#1 1\else
\ifx\propchk#1 1\else
0\fi\fi
}
\begin{document}
\shothms
\chapter{My Chapter}
Chapter text
\section{One}
blah blah
\section{Two}
\begin{theorem}
Bloh \textbf{Blah} \today
\end{theorem}
blih blih \textit{blow}
more blah
\begin{proposition}
Blah$^2$
\end{proposition}
Finis
\endshothms
\end{document}
부록
섹션 형식을 덜 지정하려면 다음 \testmacros
과 같이 재정의할 수 있습니다.
\newcommand\testmacros[1]{%
\ifx\chapter#1\addcytoks{\stepcounter{chapter}\par\noindent Chapter
\thechapter:~}\gdef\addarg{T}\else
\ifx\section#1\addcytoks{\stepcounter{section}\par\noindent Section
\thesection:~}\gdef\addarg{T}\else
\gdef\addarg{F}\fi\fi
}
~를 야기하는