Skip to content

Commit 3ca3a99

Browse files
committed
latex math: remove line at the end of equation* environment
1 parent b6223d8 commit 3ca3a99

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/latex/raw.ml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,20 @@ let ocamltag tag pp ppf x = create2 "ocamltag" Fmt.string pp ppf tag x
209209

210210
let math ppf x = Fmt.pf ppf {|$%s$|} x
211211

212+
let remove_empty_last_line x =
213+
let rec find_last_line pos x =
214+
if pos < 0 then x
215+
else
216+
match x.[pos] with
217+
| ' ' | '\012' | '\n' | '\r' | '\t' -> find_last_line (pos - 1) x
218+
| _ -> if pos = String.length x - 1 then x else String.sub x 0 (pos + 1)
219+
in
220+
find_last_line (String.length x - 1) x
221+
212222
let equation ppf x =
213223
let name = "equation*" in
214224
mbegin ppf name;
215225
Fmt.cut ppf ();
216-
Fmt.string ppf x;
226+
Fmt.string ppf (remove_empty_last_line x);
217227
Fmt.cut ppf ();
218228
mend ppf name

test/generators/latex/Markup.tex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ \subsection{Math\label{math}}%
9191
\f\relax{x} = \int_{-\infty}^\infty
9292
\f\hat\xi\,e^{2 \pi i \xi x}
9393
\,d\xi
94-
9594
\end{equation*}
9695

9796
\subsection{Modules\label{modules}}%

0 commit comments

Comments
 (0)