From 915cfc9133498fac1d74b3dfb6063d39b321f795 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sat, 12 Oct 2024 10:56:27 -0400 Subject: [PATCH 1/7] Use fixed width text for compound variable names `capacitor` makes sense as code but does not make as much sense inside of latex output. When you look at it, it italics each of the letters which makes it look like its c times a times ..., which isn't quite right. Instead, this uses `\texttt{name}` in order to more clearly delineate a value which is a compound name. Using the fixed width text also looks quite "computer-y" so it has a nice connection to `verbose` and is clearly a "computer variable" in the expression. --- src/latexify_recipes.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/latexify_recipes.jl b/src/latexify_recipes.jl index 65b881411..30c64c7b8 100644 --- a/src/latexify_recipes.jl +++ b/src/latexify_recipes.jl @@ -193,7 +193,12 @@ 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 + return LaTeXString(string("\\texttt", "{", sym, "}")) + else + return sym + end end !iscall(O) && return O From 185f3e9bb9b05e82b4176b063e07ddc24dfbad88 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sat, 12 Oct 2024 16:26:10 -0400 Subject: [PATCH 2/7] re-sym --- src/latexify_recipes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/latexify_recipes.jl b/src/latexify_recipes.jl index 30c64c7b8..7fa8eb8ee 100644 --- a/src/latexify_recipes.jl +++ b/src/latexify_recipes.jl @@ -197,7 +197,7 @@ function _toexpr(O) if length(sym) > 1 return LaTeXString(string("\\texttt", "{", sym, "}")) else - return sym + return Symbol(sym) end end !iscall(O) && return O From bff9903a8ddb340ffc6ed8482ab40d4fbc1daf5f Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 20 Oct 2024 04:02:36 -0400 Subject: [PATCH 3/7] Update integral1.txt --- test/latexify_refs/integral1.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/latexify_refs/integral1.txt b/test/latexify_refs/integral1.txt index 3f8fa1ea0..dbc286bae 100644 --- a/test/latexify_refs/integral1.txt +++ b/test/latexify_refs/integral1.txt @@ -1,3 +1,3 @@ \begin{equation} -\int_{0}^{1)} dx x +\\int_{0}^{1)} \\texttt{dx} x \end{equation} From a1a317967e13f16a1d8f535afc5334bcbed6adb1 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 20 Oct 2024 04:20:51 -0400 Subject: [PATCH 4/7] Handle compound unicode --- src/latexify_recipes.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/latexify_recipes.jl b/src/latexify_recipes.jl index 7fa8eb8ee..4f5925dc3 100644 --- a/src/latexify_recipes.jl +++ b/src/latexify_recipes.jl @@ -194,6 +194,8 @@ function _toexpr(O) if issym(O) sym = string(nameof(O)) sym = replace(sym, NAMESPACE_SEPARATOR => ".") + sym = Latexify.unicode2latex(sym) + sym = replace(sym, "_"=>"\\_") if length(sym) > 1 return LaTeXString(string("\\texttt", "{", sym, "}")) else From ae7aab9f627330e30fb6d37673abe08116de0f36 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 20 Oct 2024 04:40:32 -0400 Subject: [PATCH 5/7] only do replacements in compound strings --- src/latexify_recipes.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/latexify_recipes.jl b/src/latexify_recipes.jl index 4f5925dc3..0e895e0be 100644 --- a/src/latexify_recipes.jl +++ b/src/latexify_recipes.jl @@ -194,9 +194,9 @@ function _toexpr(O) if issym(O) sym = string(nameof(O)) sym = replace(sym, NAMESPACE_SEPARATOR => ".") - sym = Latexify.unicode2latex(sym) - sym = replace(sym, "_"=>"\\_") if length(sym) > 1 + sym = Latexify.unicode2latex(sym) + sym = replace(sym, "_"=>"\\_") return LaTeXString(string("\\texttt", "{", sym, "}")) else return Symbol(sym) From 244dd14b8821534992bafaf8c19aa64cb0109517 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 20 Oct 2024 05:04:07 -0400 Subject: [PATCH 6/7] update integral1 --- test/latexify_refs/integral1.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/latexify_refs/integral1.txt b/test/latexify_refs/integral1.txt index dbc286bae..3f8fa1ea0 100644 --- a/test/latexify_refs/integral1.txt +++ b/test/latexify_refs/integral1.txt @@ -1,3 +1,3 @@ \begin{equation} -\\int_{0}^{1)} \\texttt{dx} x +\int_{0}^{1)} dx x \end{equation} From a565638e8fef610de35d20f0e072a379ddfdb81c Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 20 Oct 2024 07:23:29 -0400 Subject: [PATCH 7/7] update refs --- test/latexify_refs/integral1.txt | 2 +- test/latexify_refs/integral2.txt | 2 +- test/latexify_refs/integral3.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/latexify_refs/integral1.txt b/test/latexify_refs/integral1.txt index 3f8fa1ea0..d03e515c2 100644 --- a/test/latexify_refs/integral1.txt +++ b/test/latexify_refs/integral1.txt @@ -1,3 +1,3 @@ \begin{equation} -\int_{0}^{1)} dx x +\int_{0}^{1)} \texttt{dx} x \end{equation} diff --git a/test/latexify_refs/integral2.txt b/test/latexify_refs/integral2.txt index 427aeff95..3e8ba3144 100644 --- a/test/latexify_refs/integral2.txt +++ b/test/latexify_refs/integral2.txt @@ -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} diff --git a/test/latexify_refs/integral3.txt b/test/latexify_refs/integral3.txt index ee9d552c6..2857cd437 100644 --- a/test/latexify_refs/integral3.txt +++ b/test/latexify_refs/integral3.txt @@ -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}