mirror of
https://github.com/jgm/pandoc.git
synced 2026-07-11 11:57:16 +00:00
a3fba6d83e
Closes #8872. In the current implementation , theorem labels in `theoremEnvironment` are determined by the `LastLabel` in the current state. This approach works well when the `\label{label_name}` is placed at the end of the theorem body. However, when a label is placed at the beginning of the theorem (another common practice) and additional labels follow in the theorem body, `theoremEnvironment` incorrectly picks the last label (e.g., `\label{item2}` in #8872). This patch addresses the issue by extracting the label extraction independently of the `LastLabel` state.
951 B
951 B
% pandoc -f latex -t native
\documentclass{amsart}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}\label{thm}
\begin{enumerate}
\item \label{item1}text1
\item \label{item2}text2
\item text3
\end{enumerate}
\end{theorem}
\end{document}
^D
[ Div
( "thm" , [ "theorem" ] , [] )
[ Para
[ Strong [ Str "Theorem" , Space , Str "1" ]
, Str "."
, Space
, Space
, Emph []
]
, OrderedList
( 1 , DefaultStyle , DefaultDelim )
[ [ Para
[ Emph
[ Span ( "item1" , [] , [ ( "label" , "item1" ) ] ) []
, Str "text1"
]
]
]
, [ Para
[ Emph
[ Span ( "item2" , [] , [ ( "label" , "item2" ) ] ) []
, Str "text2"
]
]
]
, [ Para [ Emph [ Str "text3" ] ] ]
]
]
]