mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-30 17:59:17 +08:00
0bbbdbcdb6
Certain environments in LaTeX will trigger math mode and can't occur within math mode: e.g., `align` or `equation`. Previously we "downshifted" these, parsing an `align` environment as a Math element with `aligned`, and an `equation` environment as a regular display math element. With this shift, we put these in Math inlines but retain the original environments. This works because: 1) texmath handles these environments just fine, 2) and so does MathJax; 3) when writing LaTeX we detect these environments in Math elements and emit them verbatim instead of putting them in `$..$` or `$$..$$`. Closes #9711. Closes #9296.
310 lines
5.4 KiB
Markdown
310 lines
5.4 KiB
Markdown
```
|
|
% pandoc -f latex -t native
|
|
Figure \ref{fig:1}
|
|
^D
|
|
[ Para
|
|
[ Str "Figure"
|
|
, Space
|
|
, Link
|
|
( ""
|
|
, []
|
|
, [ ( "reference-type" , "ref" )
|
|
, ( "reference" , "fig:1" )
|
|
]
|
|
)
|
|
[ Str "[fig:1]" ]
|
|
( "#fig:1" , "" )
|
|
]
|
|
]
|
|
```
|
|
|
|
```
|
|
% pandoc -f latex -t native
|
|
Figure \cref{fig:1}
|
|
^D
|
|
[ Para
|
|
[ Str "Figure"
|
|
, Space
|
|
, Link
|
|
( ""
|
|
, []
|
|
, [ ( "reference-type" , "ref+label" )
|
|
, ( "reference" , "fig:1" )
|
|
]
|
|
)
|
|
[ Str "[fig:1]" ]
|
|
( "#fig:1" , "" )
|
|
]
|
|
]
|
|
```
|
|
|
|
```
|
|
% pandoc -f latex -t native
|
|
Figure \vref{fig:1}
|
|
^D
|
|
[ Para
|
|
[ Str "Figure"
|
|
, Space
|
|
, Link
|
|
( ""
|
|
, []
|
|
, [ ( "reference-type" , "ref" )
|
|
, ( "reference" , "fig:1" )
|
|
]
|
|
)
|
|
[ Str "[fig:1]" ]
|
|
( "#fig:1" , "" )
|
|
]
|
|
]
|
|
```
|
|
|
|
```
|
|
% pandoc -f latex -t native
|
|
\autoref{fig:flowchart}
|
|
^D
|
|
[ Para
|
|
[ Link
|
|
( ""
|
|
, []
|
|
, [ ( "reference-type" , "ref+label" )
|
|
, ( "reference" , "fig:flowchart" )
|
|
]
|
|
)
|
|
[ Str "[fig:flowchart]" ]
|
|
( "#fig:flowchart" , "" )
|
|
]
|
|
]
|
|
```
|
|
|
|
```
|
|
% pandoc -f latex -t native
|
|
Accuracy~\eqref{eq:Accuracy} is the proportion, measuring true results among all results.
|
|
|
|
\begin{equation}
|
|
\label{eq:Accuracy}
|
|
Accuracy = \frac{t_p + t_n}{t_p + f_p + f_n + t_n}
|
|
\end{equation}
|
|
^D
|
|
[ Para
|
|
[ Str "Accuracy\160"
|
|
, Link
|
|
( ""
|
|
, []
|
|
, [ ( "reference-type" , "eqref" )
|
|
, ( "reference" , "eq:Accuracy" )
|
|
]
|
|
)
|
|
[ Str "[eq:Accuracy]" ]
|
|
( "#eq:Accuracy" , "" )
|
|
, Space
|
|
, Str "is"
|
|
, Space
|
|
, Str "the"
|
|
, Space
|
|
, Str "proportion,"
|
|
, Space
|
|
, Str "measuring"
|
|
, Space
|
|
, Str "true"
|
|
, Space
|
|
, Str "results"
|
|
, Space
|
|
, Str "among"
|
|
, Space
|
|
, Str "all"
|
|
, Space
|
|
, Str "results."
|
|
]
|
|
, Para
|
|
[ Math
|
|
DisplayMath
|
|
"\\begin{equation}\n \\label{eq:Accuracy}\n Accuracy = \\frac{t_p + t_n}{t_p + f_p + f_n + t_n}\n\\end{equation}"
|
|
]
|
|
]
|
|
```
|
|
|
|
```
|
|
% pandoc -f latex -t native
|
|
\begin{figure}
|
|
\includegraphics{command/SVG_logo.svg}
|
|
\caption{Logo}
|
|
\label{fig:Logo}
|
|
\end{figure}
|
|
|
|
Figure \ref{fig:Logo} illustrated the SVG logo
|
|
^D
|
|
[ Figure
|
|
( "fig:Logo" , [] , [] )
|
|
(Caption Nothing [ Plain [ Str "Logo" ] ])
|
|
[ Plain
|
|
[ Image ( "" , [] , [] ) [] ( "command/SVG_logo.svg" , "" )
|
|
]
|
|
]
|
|
, Para
|
|
[ Str "Figure"
|
|
, Space
|
|
, Link
|
|
( ""
|
|
, []
|
|
, [ ( "reference-type" , "ref" )
|
|
, ( "reference" , "fig:Logo" )
|
|
]
|
|
)
|
|
[ Str "1" ]
|
|
( "#fig:Logo" , "" )
|
|
, Space
|
|
, Str "illustrated"
|
|
, Space
|
|
, Str "the"
|
|
, Space
|
|
, Str "SVG"
|
|
, Space
|
|
, Str "logo"
|
|
]
|
|
]
|
|
```
|
|
|
|
```
|
|
% pandoc -f latex -t native
|
|
\chapter{One}
|
|
\begin{figure}
|
|
\includegraphics{command/SVG_logo.svg}
|
|
\caption{Logo}
|
|
\label{fig:Logo}
|
|
\end{figure}
|
|
|
|
\begin{figure}
|
|
\includegraphics{command/SVG_logo2.svg}
|
|
\caption{Logo2}
|
|
\label{fig:Logo2}
|
|
\end{figure}
|
|
|
|
\chapter{Two}
|
|
|
|
\section{Subone}
|
|
|
|
\begin{figure}
|
|
\includegraphics{command/SVG_logo3.svg}
|
|
\caption{Logo3}
|
|
\label{fig:Logo3}
|
|
\end{figure}
|
|
|
|
Figure \ref{fig:Logo} illustrated the SVG logo
|
|
|
|
Figure \ref{fig:Logo2} illustrated the SVG logo
|
|
|
|
Figure \ref{fig:Logo3} illustrated the SVG logo
|
|
^D
|
|
[ Header 1 ( "one" , [] , [] ) [ Str "One" ]
|
|
, Figure
|
|
( "fig:Logo" , [] , [] )
|
|
(Caption Nothing [ Plain [ Str "Logo" ] ])
|
|
[ Plain
|
|
[ Image ( "" , [] , [] ) [] ( "command/SVG_logo.svg" , "" )
|
|
]
|
|
]
|
|
, Figure
|
|
( "fig:Logo2" , [] , [] )
|
|
(Caption Nothing [ Plain [ Str "Logo2" ] ])
|
|
[ Plain
|
|
[ Image ( "" , [] , [] ) [] ( "command/SVG_logo2.svg" , "" )
|
|
]
|
|
]
|
|
, Header 1 ( "two" , [] , [] ) [ Str "Two" ]
|
|
, Header 2 ( "subone" , [] , [] ) [ Str "Subone" ]
|
|
, Figure
|
|
( "fig:Logo3" , [] , [] )
|
|
(Caption Nothing [ Plain [ Str "Logo3" ] ])
|
|
[ Plain
|
|
[ Image ( "" , [] , [] ) [] ( "command/SVG_logo3.svg" , "" )
|
|
]
|
|
]
|
|
, Para
|
|
[ Str "Figure"
|
|
, Space
|
|
, Link
|
|
( ""
|
|
, []
|
|
, [ ( "reference-type" , "ref" )
|
|
, ( "reference" , "fig:Logo" )
|
|
]
|
|
)
|
|
[ Str "1.1" ]
|
|
( "#fig:Logo" , "" )
|
|
, Space
|
|
, Str "illustrated"
|
|
, Space
|
|
, Str "the"
|
|
, Space
|
|
, Str "SVG"
|
|
, Space
|
|
, Str "logo"
|
|
]
|
|
, Para
|
|
[ Str "Figure"
|
|
, Space
|
|
, Link
|
|
( ""
|
|
, []
|
|
, [ ( "reference-type" , "ref" )
|
|
, ( "reference" , "fig:Logo2" )
|
|
]
|
|
)
|
|
[ Str "1.2" ]
|
|
( "#fig:Logo2" , "" )
|
|
, Space
|
|
, Str "illustrated"
|
|
, Space
|
|
, Str "the"
|
|
, Space
|
|
, Str "SVG"
|
|
, Space
|
|
, Str "logo"
|
|
]
|
|
, Para
|
|
[ Str "Figure"
|
|
, Space
|
|
, Link
|
|
( ""
|
|
, []
|
|
, [ ( "reference-type" , "ref" )
|
|
, ( "reference" , "fig:Logo3" )
|
|
]
|
|
)
|
|
[ Str "2.1" ]
|
|
( "#fig:Logo3" , "" )
|
|
, Space
|
|
, Str "illustrated"
|
|
, Space
|
|
, Str "the"
|
|
, Space
|
|
, Str "SVG"
|
|
, Space
|
|
, Str "logo"
|
|
]
|
|
]
|
|
```
|
|
|
|
|
|
```
|
|
% pandoc -f latex -t native
|
|
\label{section} Section \ref{section}
|
|
^D
|
|
[ Para
|
|
[ Span ( "section" , [] , [ ( "label" , "section" ) ] ) []
|
|
, Space
|
|
, Str "Section"
|
|
, Space
|
|
, Link
|
|
( ""
|
|
, []
|
|
, [ ( "reference-type" , "ref" )
|
|
, ( "reference" , "section" )
|
|
]
|
|
)
|
|
[ Str "[section]" ]
|
|
( "#section" , "" )
|
|
]
|
|
]
|
|
```
|