Skip to content

Commit

Permalink
TeX writer: superscripted prime should just be '.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgm committed Dec 3, 2024
1 parent 0b7bb76 commit 721bb5c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
8 changes: 5 additions & 3 deletions src/Text/TeXMath/Writers/TeX.hs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ writeExp o@(EMathOperator s) = do
tell [Grouped math]
writeExp (ESymbol Ord (T.unpack -> [c])) -- do not render "invisible operators"
| c `elem` ['\x2061'..'\x2064'] = return () -- see 3.2.5.5 of mathml spec
writeExp (ESymbol Ord "\8242") = tell [Literal "'"] -- render prime as ', #246
writeExp (ESymbol Ord "\8242") = tell [Token '\''] -- render prime as ', #246
writeExp (ESymbol t s) = do
s' <- getTeXMathM s
when (t == Bin || t == Rel) $ tell [Space]
Expand Down Expand Up @@ -199,8 +199,10 @@ writeExp (ESub b e1) = do
tellGroup (writeExp e1)
writeExp (ESuper b e1) = do
(if isFancy b then tellGroup else id) $ writeExp b
tell [Token '^']
tellGroup (writeExp e1)
case e1 of
ESymbol Ord "\8242" -> tell [Token '\'']
_ -> do tell [Token '^']
tellGroup (writeExp e1)
writeExp (ESubsup b e1 e2) = do
(if isFancy b then tellGroup else id) $ writeExp b
tell [Token '_']
Expand Down
10 changes: 5 additions & 5 deletions test/writer/tex/complex3.test
Original file line number Diff line number Diff line change
Expand Up @@ -7686,7 +7686,7 @@
\begin{matrix}
{2{\sum{ab}}} & \\
x^{'3} & \\
{{{f^{'}{(x)}} + {\sin\cos\theta}} = 1} & \\
{{{f'{(x)}} + {\sin\cos\theta}} = 1} & \\
{{{f{(z)}} = {\sum\limits_{n = 0}^{\infty}{a_{n}z^{n}}}}\text{, }{{|z| < R}\hspace{0pt}{({R \neq 0})}}} & \\
{\left. \int{}_{C}{\left( {\sum\limits_{n = 0}^{\infty}{a_{n}z^{n}}} \right){\mathbb{d}z}} \right. = {\sum\limits_{n = 0}^{\infty}{a_{n}\left. \int{}_{C}{z^{n}{\mathbb{d}z}} \right.}}} & \\
{{\lim\limits_{n\rightarrow\infty}\left| \left. \int{}_{C}{\left\lbrack {{f{(z)}} - {\sum\limits_{k = 0}^{n}{a_{k}z^{k}}}} \right\rbrack{\mathbb{d}z}} \right. \right|} = 0} & \\
Expand Down Expand Up @@ -7782,7 +7782,7 @@ c & d
\begin{array}{r}
{{{\mathbb{D}_{x\hspace{0pt}x}y} - y} = 0} \\
{{y{(0)}} = 1} \\
{{y^{'}(0)} = 0}
{{y'(0)} = 0}
\end{array} & \\
{{y(x)} = {{\frac{1}{3}e^{{- \sqrt[3]{({- 1})}}x}} + {\frac{2}{3}e^{\frac{1}{2}\sqrt[3]{({- 1})}x}{\cos{\frac{1}{2}\sqrt{3}\sqrt[3]{\left( {- 1} \right)}x}}}}} & \\
{{y(t)} = {2{\tan\left( {{2t} - {\frac{1}{4}\pi}} \right)}}} & \\
Expand Down Expand Up @@ -7838,8 +7838,8 @@ t & x & y & z \\
{1 = 3}
\end{matrix} & \\
\begin{matrix}
{{A_{1} = {{N_{0}{({\lambda;\Omega^{'}})}} - {\varphi{({\lambda;\Omega^{'}})}}}}\text{,}} \\
{{A_{2} = {{\varphi{({\lambda;\Omega^{'}})}} - {\varphi{({\lambda;\Omega})}}}}\text{,}} \\
{{A_{1} = {{N_{0}{({\lambda;\Omega'})}} - {\varphi{({\lambda;\Omega'})}}}}\text{,}} \\
{{A_{2} = {{\varphi{({\lambda;\Omega'})}} - {\varphi{({\lambda;\Omega})}}}}\text{,}} \\
{{A_{3} = {\mathcal{N}{({\lambda;\omega})}}}\text{.}}
\end{matrix} & \\
\begin{matrix}
Expand Down Expand Up @@ -7936,7 +7936,7 @@ b_{2\hspace{0pt}1} & b_{2\hspace{0pt}2}
{{\int_{a}^{b}{{f{(x)}}{\mathbb{d}x}}} = {\lim\limits_{{\parallel P\parallel}\rightarrow 0}{\sum\limits_{i = 1}^{n}{{f\left( {\overline{x}}_{i} \right)}{\Delta x_{i}}}}}} & \\
{{\int_{a}^{b}{{f{(x)}}{\mathbb{d}x}}} = {\lim\limits_{n\rightarrow\infty}{\frac{b - a}{n}{\sum\limits_{i = 1}^{n}{f\left( {a + {i\frac{b - a}{n}}} \right)}}}}} & \\
{{\int_{0}^{2}{x^{5}\sqrt{x^{3} + 1}{\mathbb{d}x}}} = {\int_{1}^{3}{\frac{2}{3}u\frac{\sqrt{\left( u^{2} \right)}}{\left( {u^{2} - 1} \right)^{\frac{2}{3}}}\left( {{u^{2}\left( {u^{2} - 1} \right)^{\frac{2}{3}}} - \left( {u^{2} - 1} \right)^{\frac{2}{3}}} \right){\mathbb{d}u}}}} & \\
{\left. \int{{f{({g{(x)}})}}{g^{'}{(x)}}{\mathbb{d}x}} \right. = \left. \int{{f{(u)}}{\mathbb{d}u}} \right.} & \\
{\left. \int{{f{({g{(x)}})}}{g'{(x)}}{\mathbb{d}x}} \right. = \left. \int{{f{(u)}}{\mathbb{d}u}} \right.} & \\
{x = {2{\sum\limits_{n = 1}^{100}{n{({n - 1})}}}}} & \\
{{\lim\limits_{x\rightarrow 0}{\sin\left( \frac{1}{x} \right)}} = {{- 1}..1}} & \\
{{h{({i,j})}} = {{{({2 - j})}{g{(i)}}} + {{({j - 1})}{f{({g{(i)}})}}}}} & \\
Expand Down
2 changes: 1 addition & 1 deletion test/writer/tex/moAprime16.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
, EDelimited "(" ")" [ Right (EIdentifier "x") ]
]
>>> tex
f^{'}(x) = f^{'}(x)
f^{'}(x) = f'(x)
2 changes: 1 addition & 1 deletion test/writer/tex/primes1.test
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
, ESuper (ESymbol Accent "'") (ESymbol Accent "'")
]
>>> tex
x^{2} + 2^{2} + x^{'} + x^{'} + x^{\operatorname{''}} + x\prime + {x^{'}}^{'} + {x^{'}}^{2} + x^{' + '} + {x^{'}}^{'} + x^{'^{'}} + '^{'} + '^{'}
x^{2} + 2^{2} + x' + x^{'} + x^{\operatorname{''}} + x\prime + {x^{'}}^{'} + {x^{'}}^{2} + x^{' + '} + {x^{'}}^{'} + x^{'^{'}} + '^{'} + '^{'}
2 changes: 1 addition & 1 deletion test/writer/tex/primes2.test
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
, ESuper (EIdentifier "H") (ESymbol Accent "\8279")
]
>>> tex
H^{"}H^{'}H^{*}H^{`}H^{ª}H^{{^\circ}}H^{²}H^{³}H^{´}H^{¹}H^{º}H^{‘}H^{’}H^{‚}H^{‛}H^{``}H^{"}H^{„}H^{‟}H^{'}H^{''}H^{'''}H^{\backprime}H^{‶}H^{‷}H^{⁗}
H^{"}H^{'}H^{*}H^{`}H^{ª}H^{{^\circ}}H^{²}H^{³}H^{´}H^{¹}H^{º}H^{‘}H^{’}H^{‚}H^{‛}H^{``}H^{"}H^{„}H^{‟}H'H^{''}H^{'''}H^{\backprime}H^{‶}H^{‷}H^{⁗}

0 comments on commit 721bb5c

Please sign in to comment.