aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2020-07-23 11:11:28 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2020-07-23 11:11:28 -0700
commita0e3172a0bb9f0cb69ede824086ea4655a71eff2 (patch)
tree69c21c87da0f62dac2e63952e0ab634982cf541d
parent98c922ad43b599ad38da8782de64bfb2d564fbac (diff)
downloadpandoc-a0e3172a0bb9f0cb69ede824086ea4655a71eff2.tar.gz
Further improvements to ams theorem support, and a test.
See #1608.
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs5
-rw-r--r--test/command/1608.md41
2 files changed, 44 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index ebdee1b1a..e571da5ad 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -871,6 +871,7 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList
, ("_", lit "_")
, ("{", lit "{")
, ("}", lit "}")
+ , ("qed", lit "\a0\x25FB")
-- old TeX commands
, ("em", extractSpaces emph <$> inlines)
, ("it", extractSpaces emph <$> inlines)
@@ -1915,7 +1916,7 @@ addQed bs =
-> B.Many (s Seq.|> Para (ils ++ B.toList qedSign))
_ -> bs <> B.para qedSign
where
- qedSign = B.spanWith ("",["qed"],[]) "\x220E"
+ qedSign = B.str "\xa0\x25FB"
environment :: PandocMonad m => LP m Blocks
environment = try $ do
@@ -1968,7 +1969,7 @@ theoremEnvironment name = do
DefinitionStyle -> B.strong
RemarkStyle -> B.emph
let title = titleEmph (B.text (theoremName tspec) <> number)
- <> optTitle <> space
+ <> optTitle <> "." <> space
return $ divWith (fromMaybe "" mblabel, [name], []) $ addTitle title
$ case theoremStyle tspec of
PlainStyle -> walk italicize bs
diff --git a/test/command/1608.md b/test/command/1608.md
new file mode 100644
index 000000000..e9fd5232a
--- /dev/null
+++ b/test/command/1608.md
@@ -0,0 +1,41 @@
+```
+% pandoc -f latex -t native
+\newtheorem{theorem}{Theorem}
+\newtheorem{corollary}[theorem]{Corollary}
+\newtheorem{lemma}[theorem]{Lemma}
+\theoremstyle{definition}
+\newtheorem{definition}[theorem]{Definition}
+\theoremstyle{remark}
+\newtheorem{remark}{Remark}
+
+\begin{definition}[right-angled triangles] \label{def:tri}
+A \emph{right-angled triangle} is a triangle whose sides of length~\(a\), \(b\) and~\(c\), in some permutation of order, satisfies \(a^2+b^2=c^2\).
+\end{definition}
+
+\begin{lemma}
+The triangle with sides of length~\(3\), \(4\) and~\(5\) is right-angled.
+\end{lemma}
+
+\begin{proof}
+This lemma follows from \cref{def:tri} since \(3^2+4^2=9+16=25=5^2\).
+\end{proof}
+
+\begin{theorem}[Pythagorean triplets] \label{thm:py}
+Triangles with sides of length \(a=p^2-q^2\), \(b=2pq\) and \(c=p^2+q^2\) are right-angled triangles.
+\end{theorem}
+
+\begin{remark}
+These are all pretty interesting facts.
+\end{remark}
+^D
+[Div ("def:tri",["definition"],[])
+ [Para [Strong [Str "Definition",Space,Str "1"],Space,Str "(right-angled",Space,Str "triangles).",Space,Space,Str "A",Space,Emph [Str "right-angled",Space,Str "triangle"],Space,Str "is",Space,Str "a",Space,Str "triangle",Space,Str "whose",Space,Str "sides",Space,Str "of",Space,Str "length\160",Math InlineMath "a",Str ",",Space,Math InlineMath "b",Space,Str "and\160",Math InlineMath "c",Str ",",Space,Str "in",Space,Str "some",Space,Str "permutation",Space,Str "of",Space,Str "order,",Space,Str "satisfies",Space,Math InlineMath "a^2+b^2=c^2",Str "."]]
+,Div ("",["lemma"],[])
+ [Para [Strong [Str "Lemma",Space,Str "2"],Str ".",Space,Space,Emph [Str "The",Space,Str "triangle",Space,Str "with",Space,Str "sides",Space,Str "of",Space,Str "length\160",Math InlineMath "3",Str ",",Space,Math InlineMath "4",Space,Str "and\160",Math InlineMath "5",Space,Str "is",Space,Str "right-angled."]]]
+,Div ("",["proof"],[])
+ [Para [Emph [Str "Proof."],Space,Str "This",Space,Str "lemma",Space,Str "follows",Space,Str "from",Space,Link ("",[],[("reference-type","ref"),("reference","def:tri")]) [Str "Definition",Str "\160",Str "1"] ("#def:tri",""),Space,Str "since",Space,Math InlineMath "3^2+4^2=9+16=25=5^2",Str ".",Str "\160\9723"]]
+,Div ("thm:py",["theorem"],[])
+ [Para [Strong [Str "Theorem",Space,Str "3"],Space,Str "(Pythagorean",Space,Str "triplets).",Space,Space,Emph [Str "Triangles",Space,Str "with",Space,Str "sides",Space,Str "of",Space,Str "length",Space,Math InlineMath "a=p^2-q^2",Str ",",Space,Math InlineMath "b=2pq",Space,Str "and",Space,Math InlineMath "c=p^2+q^2",Space,Str "are",Space,Str "right-angled",Space,Str "triangles."]]]
+,Div ("",["remark"],[])
+ [Para [Emph [Str "Remark",Space,Str "1"],Str ".",Space,Space,Str "These",Space,Str "are",Space,Str "all",Space,Str "pretty",Space,Str "interesting",Space,Str "facts."]]]
+```