Skip to content

Commit

Permalink
Merge pull request #1305 from JuliaSymbolics/fixedwidth_tex
Browse files Browse the repository at this point in the history
Use fixed width text for compound variable names
  • Loading branch information
ChrisRackauckas authored Oct 20, 2024
2 parents ab3ecdc + a565638 commit 630bd7a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/latexify_recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,14 @@ function _toexpr(O)
end
if issym(O)
sym = string(nameof(O))
return Symbol(replace(sym, NAMESPACE_SEPARATOR => "."))
sym = replace(sym, NAMESPACE_SEPARATOR => ".")
if length(sym) > 1
sym = Latexify.unicode2latex(sym)
sym = replace(sym, "_"=>"\\_")
return LaTeXString(string("\\texttt", "{", sym, "}"))
else
return Symbol(sym)
end
end
!iscall(O) && return O

Expand Down
2 changes: 1 addition & 1 deletion test/latexify_refs/integral1.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
\begin{equation}
\int_{0}^{1)} dx x
\int_{0}^{1)} \texttt{dx} x
\end{equation}
2 changes: 1 addition & 1 deletion test/latexify_refs/integral2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
\begin{equation}
\int_{-\infty}^{\infty)} dx \left( u\left( x \right) \right)^{2}
\int_{-\infty}^{\infty)} \texttt{dx} \left( u\left( x \right) \right)^{2}
\end{equation}
2 changes: 1 addition & 1 deletion test/latexify_refs/integral3.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
\begin{equation}
\int_{ - z}^{u\left( x \right))} dx x^{2}
\int_{ - z}^{u\left( x \right))} \texttt{dx} x^{2}
\end{equation}

0 comments on commit 630bd7a

Please sign in to comment.