
Quiero que los nombres de los teoremas aparezcan en el margen. Intenté usar las notas al margen para hacer esto pero no pude hacerlo.
Aquí hay una imagen de lo que estoy tratando de hacer. La línea superior es cómo funciona el entorno del teorema de forma predeterminada; a continuación se muestra lo que me gustaría.
Esto es lo que intenté hacer, aunque debo admitir que no entiendo bien cómo hacer algo como esto.
\newenivorment{margintheorem}[#2]{
\begin{theorem}[\marginnote{#2}]
\end{theorem}
}
Respuesta1
Puedes definir indirectamente el theorem
entorno:
\documentclass{article}
\usepackage{amsthm,marginnote,xparse}
\newtheorem{theoreminner}{Theorem}
\NewDocumentEnvironment{theorem}{o}
{\theoreminner\IfValueT{#1}{\marginnote{\normalfont\footnotesize#1}}}
{\endtheoreminner}
\reversemarginpar
\begin{document}
\begin{theorem}
This theorem has no attribution.
\end{theorem}
\begin{theorem}[theorem name]
This theorem has a name.
\end{theorem}
\end{document}
Respuesta2
Su pregunta carece de algunos detalles importantes y, en particular, no especifica si está utilizando o no un paquete en particular para definir sus entornos "tipo teorema". Asumiré que estás usando amsthm
.
La siguiente solución piratea directamente la amsthm
definición del \@begintheorem
comando de 's' y, por lo tanto, se aplica automáticamente a todo tipo de entornos "similares a teoremas" (proposiciones, lemas, definiciones...). Se basa en el uso del \marginpar
comando del kernel LaTeX: esto complica un poco las cosas, porque este comando debe ejecutarse "en modo de párrafo externo". De hecho, escribí el código exactamente con la intención de mostrar que \marginpar
era posible una solución basada en el comando original.
% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.
\usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.
% \usepackage{amsmath} % not essential, but you probably want it too
\usepackage{amsthm}
\usepackage{etoolbox} % for "\patchcmd"/"\pretocmd"
%%%%%%%% BEGIN WIZARDRY %%%%%%%%
\makeatletter
\wlog{****************************************}
\patchcmd{\@begintheorem}{% search for:
\@ifempty{#3}{\let\thmnote\@gobble}{\let\thmnote\@iden}%
\thm@swap\swappedhead\thmhead{#1}{#2}{#3}%
}{% replace with:
\let\thmnote\@gobble
\thm@swap\swappedhead\thmhead{#1}{#2}{}%
}{% execute if succeeded:
\wlog{>>> 1st patch succeeded.}
}{% execute if failed:
\wlog{>>> 1st patch FAILED!}
}
\pretocmd{\@begintheorem}{% prepended code:
\@ifnotempty{#3}{\def\@thm@marginal@note@text{#3}}%
}{% execute if succeeded:
\wlog{>>> 2nd patch succeeded.}
}{% execute if failed:
\wlog{>>> 2nd patch FAILED!}
}
\wlog{****************************************}
\newcommand*\@thm@marginal@note@text{}
\newcommand*\@thm@marginal@note@helper{%
\begingroup \setbox\z@ \lastbox \endgroup
\marginnote{\@thm@marginal@note@text}%
}
\dth@everypar = \expandafter {%
\expandafter \@thm@marginal@note@helper
\the \dth@everypar
}
\makeatother
%%%%%%%% END WIZARDRY %%%%%%%%
\newcommand*{\marginnote}[1]{%
\marginpar
[\footnotesize\raggedleft #1]%
{\footnotesize\raggedright #1}%
}
\reversemarginpar % ?
\newtheorem{theorem}{Theorem}
\newtheorem{lemma} {Lemma}
\theoremstyle{definition}
\newtheorem{defin}{Definition}
\begin{document}
This text comes before the first definition.
\begin{defin}[Important definition]
A definition is \textbf{important} if and only if it is not
unimportant.
\end{defin}
And, of course:
\begin{defin}
An \textbf{unimportant} definition is one that is not important.
\end{defin}
Now a theorem:
\begin{theorem}[Important Theorem]
All theorems are important, but some theorems are more important
than others.
\end{theorem}
The proof rests on the following
\begin{lemma}[Important lemma]
Not all theorems (or lemmas) are equally important.
\end{lemma}
An unimportant theorem:
\begin{theorem}
Blah blah blah\ldots
\end{theorem}
And an unimportant lemma:
\begin{lemma}
Blah blah blah\ldots
\end{lemma}
Here is a little more text.
\end{document}
Tenga en cuenta el código anticuado y "vintage" y su uso de \expandafter
... ;-)
La salida: