
para simplificar digamos que tengo un documento con solo texto y teoremas.
Quiero mostrar solo el texto contenido en los teoremas. Por ejemplo
\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}
Solo quiero que se muestre: 1 uno 1.Uno 2.Dos Teorema:Bloh" 2.Dos
¿Es posible sin tener que encerrar el texto en un entorno adicional?
Una solución sería de alguna manera suprimir la salida normal con algún truco, por ejemplo, poner el tamaño de fuente en 0 (no logré hacerlo), excepto en los teoremas.
Gracias
EDITAR: tal vez una forma de hacerlo sería recopilar automáticamente todo el contenido de los teoremas con algunos paquetes, no mostrar el documento principal y solo mostrar lo que se ha recopilado, pero también me gustaría tener títulos de capítulos y secciones...
Respuesta1
El OP estipula "digamos que tengo un documento sólo con texto y teoremas".
Utilizo un tokencycle
pseudoentorno llamado \shothms...\endshothms
, una instancia del cual rodea todo el documento, para lograr el resultado.
Tal como está EDITADO actualmente, solo ejecutará instancias de \chapter
& \section
(sin argumentos opcionales) y theorem
& proposition
entornos. Tenga en cuenta que los argumentos opcionales de estas macros/entornos se pueden tratar mediante tokcycle
, pero no tenía ganas de invertir tiempo ni código aquí. VerAnalizar argumento por carácter al ejecutar macros integradas, por ejemplo donde se hace.
Las pruebas de macro (si se quisiera agregar macros adicionales para capturar) las realiza la \testmacros
macro
\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
}
Las pruebas de entorno (si se necesitan más) las realiza la \testenvs
macro, dada como
\newcommand\testenvs[1]{%
\ifx\thmchk#1 1\else
\ifx\propchk#1 1\else
0\fi\fi
}
dadas las definiciones del preámbulo
\def\thmchk{theorem}
\def\propchk{proposition}
El 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}
APÉNDICE
Si uno quisiera menos formato de la sección, podría redefinirlo \testmacros
como
\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
}
Resultando en