Files
Hikaru Ibayashi a3fba6d83e LaTeX reader: fix theorem label parsing (#9198)
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.
2023-11-17 18:49:03 -08:00

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" ] ] ]
        ]
    ]
]