Coder Social home page Coder Social logo

latexstrings.jl's Introduction

Build Status

LaTeXStrings

This is a small package to make it easier to type LaTeX equations in string literals in the Julia language, written by Steven G. Johnson.

With ordinary strings in Julia, to enter a string literal with embedded LaTeX equations you need to manually escape all backslashes and dollar signs: for example, $\alpha^2$ is written \$\\alpha^2\$. Also, even though IJulia is capable of displaying formatted LaTeX equations (via MathJax), an ordinary string will not exploit this. Therefore, the LaTeXStrings package defines:

  • A LaTeXString class (a subtype of String), which works like a string (for indexing, conversion, etcetera), but automatically displays as text/latex in IJulia.

  • L"..." and L"""...""" string macros which allow you to enter LaTeX equations without escaping backslashes and dollar signs (and which add the dollar signs for you if you omit them).

FAQ: Not a LaTeX renderer

LaTeXStrings does not do any rendering — its sole purpose is to make it easier to enter LaTeX-rendered strings without typing a lot of backslash escapes, as well as providing a type to tell display backends to use LaTeX rendering if possible.

Other packages like plotting software, Jupyter notebooks, Pluto, etcetera, are responsible for the LaTeX rendering (if any). For example, they might use MathJax, MathTeXEngine.jl, or other renderers. LaTeXStrings only provides the LaTeX text to these backend, and has no influence on what LaTeX features (if any) are supported.

Usage

After installing LaTeXStrings with Pkg.add("LaTeXStrings") in Julia, run

using LaTeXStrings

to load the package. At this point, you can construct LaTeXString literals with the constructor L"..." (and L"""...""" for multi-line strings); for example L"1 + \alpha^2" or L"an equation: $1 + \alpha^2$". (Note that $ is added automatically around your string, i.e. the string is interpreted as an equation, if you do not include $ yourself.)

If you want to perform string interpolation (inserting the values of other variables into your string), use %$ instead of the plain $ that you would use for interpolation in ordinary Julia strings. For example, if x=3 is a Julia variable, then L"y = %$x" will produce L"y = 3".

You can also use the lower-level constructor latexstring(args...), which works much like string(args...) except that it produces a LaTeXString result and automatically puts $ at the beginning and end of the string if an unescaped $ is not already present. Note that with latexstring(...) you do have to escape $ and \: for example, latexstring("an equation: \$1 + \\alpha^2\$"). Note that you can supply multiple arguments (of any types) to latexstring, which are converted to strings and concatenated as in the string(...) function.

Finally, you can use the lowest-level constructor LaTeXString(s). The only advantage of this is that it does not automatically put $ at the beginning and end of the string. So, if for some reason you want to use text/latex display of ordinary text (with no equations or formatting), you can use this constructor. (Note that IJulia only formats LaTeX equations; other LaTeX text-formatting commands like \emph are ignored.)

Author

This package was written by Steven G. Johnson, and is distributed under the MIT/expat license (see the LICENSE.md file).

latexstrings.jl's People

Contributors

carstenbauer avatar chrisrackauckas avatar fredrikekre avatar gustaphe avatar jakobjpeters avatar juliatagbot avatar keithwm avatar malmaud avatar quinnj avatar ranocha avatar sacha0 avatar sglyon avatar simeonschaub avatar stevengj avatar stillyslalom avatar tkelman avatar yuyichao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

latexstrings.jl's Issues

Git Tags

Would be nice to have tag/release in this repo too (in additional to the version specs in METADATA.jl).

ArgumentError: regex matching is only available for the String type

Hi all,

I used to use LaTeXStrings seamlessly, but I guess (not sure) the latest version v1.2.1 might have broken something. This simple MWE shouldt work, right?

using Plots
using LaTeXStrings
x = range(0, 10, length=100)
α = 1.0
plot(x, α*x, xaxis=L"x", yaxis=L"y", label=L"\alpha = %$α")

issuing the following error:

ArgumentError: regex matching is only available for the String type; use String(s) to convert

Stacktrace:
  [1] match(r::Regex, s::LaTeXString, i::Int64)
    @ Base ./regex.jl:317
  [2] match(r::Regex, s::LaTeXString)
    @ Base ./regex.jl:316
  [3] gr_inqtext(x::Int64, y::Int64, s::LaTeXString)
    @ Plots ~/.julia/packages/Plots/0FnGd/src/backends/gr.jl:231
...

Best

non-equations

trying to use this in Escher and running into problems because of the surrounding $s. Some parsers don't like it:

Uncaught ParseError: KaTeX parse error: Unexpected character: '$' at position 0: ̲$a+b=c$

What's the best way to work around this? The dirty way is to remove the extra $s, the nice way I think maybe is to have both LaTeXEquation and LaTeXString types.

cc @alinchis

`getindex(::LaTeXStrings.LaTeXString, ::AbstractVector{Bool})` is ambiguous (in Julia v1.7)

I found this while running tests with Aqua.jl for one of my packages.

julia> using Pkg; Pkg.activate(temp=true); Pkg.add("LaTeXStrings")
  Activating new project at `/tmp/jl_PC9tEj`
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
    Updating `/tmp/jl_PC9tEj/Project.toml`
  [b964fa9f] + LaTeXStrings v1.3.0
    Updating `/tmp/jl_PC9tEj/Manifest.toml`
  [b964fa9f] + LaTeXStrings v1.3.0

julia> using LaTeXStrings

julia> getindex(L"\alpha \beta \gamma", [true])
ERROR: MethodError: getindex(::LaTeXString, ::Vector{Bool}) is ambiguous. Candidates:
  getindex(s::AbstractString, v::AbstractVector{Bool}) in Base at strings/basic.jl:194
  getindex(s::LaTeXString, i::AbstractVector{<:Integer}) in LaTeXStrings at ~/.julia/packages/LaTeXStrings/pJ7vn/src/LaTeXStrings.jl:120
Possible fix, define
  getindex(::LaTeXString, ::AbstractVector{Bool})
Stacktrace:
 [1] top-level scope
   @ REPL[8]:1

Concatenation broken in Julia 1.0

Hi,

LaTeXString concatenation seems to be broken on 1.0:

using LaTeXStrings
L"x" * L"y"
ERROR: MethodError: no method matching iterate(::LaTeXString)
Closest candidates are:
  iterate(::LaTeXString, ::Int64) at C:\Users\nikla\.julia\packages\LaTeXStrings\Bx4do\src\LaTeXStrings.jl:63
  iterate(::AbstractString, ::Integer) at strings/basic.jl:135
  iterate(::Core.SimpleVector) at essentials.jl:578
  ...
Stacktrace:
 [1] print(::Base.GenericIOBuffer{Array{UInt8,1}}, ::LaTeXString) at .\strings\io.jl:147
 [2] #print_to_string#326(::Nothing, ::Function, ::LaTeXString, ::Vararg{LaTeXString,N} where N) at .\strings\io.jl:124
 [3] print_to_string(::LaTeXString, ::Vararg{LaTeXString,N} where N) at .\strings\io.jl:112
 [4] string(::LaTeXString, ::LaTeXString) at .\strings\io.jl:143
 [5] *(::LaTeXString, ::LaTeXString) at .\strings\basic.jl:229
 [6] top-level scope at none:0

Edit: I should also say that I'm using master and running on windows.

Support \displaystyle

I would like to display integrals and products in display mode since they look much better when the limits are included. I don't think that this feature is currently available. One way would be supporting the \displaystyle command (https://www.overleaf.com/learn/latex/display_style_in_math_mode). This is how the package TikzPictures does it.

tp = TikzPicture(L"""
\node[align=center, below, white] {
$ \displaystyle F(\omega) = \int_{-\infty}^{\infty} \! f(t)e^{-i \omega t} \, \mathrm{d}t $\\\\
$ F(\omega) = \displaystyle\int_{-\infty}^{\infty} \! f(t)\cos(\omega t) \mathrm{d}t - i \int_{-\infty}^{\infty} \! f(t)\sin(\omega t) \mathrm{d}t $\\\\
};
""", options="transform shape, scale=2.5", preamble="")

image

It can not be concatenated with other strings

My goal is to have my special character concatenated with some other strings, so that they can be used as the xlabel or ylabel of my plot. Here is an example: "Dissolved oxygen (μmol/kg)". Unfortunately, I'm unable to do that. Below are what I've tried so far:

a = L"\mu"
𝜇

b = "mol"
“mol”

C1 = join(a,b)
“$mol\molmmolumol$”

C2 = string(a,b)
“$\mu$mol”

C3 = a * b
“$\mu$mol”

C4 = [a b]
1×2 Matrix{AbstractString}:
L"$\mu$" "mol"

C5 = hcat(a,b)
1×2 Matrix{AbstractString}:
L"$\mu$" "mol"

Escaping %

Wouldn't it make sense, if the L macro also replaces, e.g. % with \% and so on?
Or would a different macro make more sense?

`text/latex` repr

Currently, in Pluto, a LaTeXString is wrapped with \text{} before being passed to MathJax. This lets LaTeXStrings with mixed text and math like the L"an equation: $1 + \alpha^2$" from your readme render properly in Pluto, but causes issues for other packages that use this MIME type targeting MathJax. You can see discussion here: fonsp/Pluto.jl#488.

Maybe instead, Base.show(io::IO, ::MIME"text/latex", s::LaTeXString) could do this, ensuring that LaTeXStrings with mixed text and math get rendered properly in Pluto (and others that use MathJax on the text/latex MIME type).

Vector Hat Notation Appearing Off of a Letter

Hello!

Hi @stevengj! Thanks for making such a wonderful tool and package. I ran into an issue, and tried to be as thorough as possible in reporting it. Let me know if you need any more info! Thanks!

Problem

Ran into an issue today that does not appear to have been reported. I was working with Plots to label one of my plots as a unit vector (arrow over a character) and was using LaTeXStrings to do it. Up until now, I have had zero issues with the package. However, when I was trying to label my unit vector in the plot, here is what it appeared as:

image

As you can see in the legend, the vectors v and w's arrow hats are misaligned. Any thoughts as to why this is?

Code Used

Here is a segment of the code I used to generate this:

plot([0, v[1]],
     [0, v[2]],
     label = "v",
     arrow = :head,
     linewidth = 5);
plot!([0, w[1]],
     [0, w[2]],
     framestyle = :zerolines,
     title = "Visualizing Geometry of Vectors",
     label = "w",
     arrow = :head,
     linewidth = 5,
     legend = :best,
     xlim = (-8, 8),
     ylim = (-5, 5));
plot!([0, v⃗[1]],
     [0, v⃗[2]],
     label = L"$vec{v}$",
     arrow = :head,
     linewidth = 5);
plot!([0, w⃗[1]],
     [0, w⃗[2]],
     label = L"$vec{w}$",
     arrow = :head,
     linewidth = 5)

Packages Info

  [7073ff75] IJulia v1.21.2
  [b964fa9f] LaTeXStrings v1.1.0
  [58dd65bb] Plotly v0.3.0
  [91a5bcdd] Plots v1.3.7

System Information

          /:-------------:\          cedarprince@obsidian 
       :-------------------::        -------------------- 
     :-----------/shhOHbmp---:\      OS: Fedora x86_64 
   /-----------omMMMNNNMMD  ---:     Host: XPS 15 7590 
  :-----------sMMMMNMNMP.    ---:    Kernel: 5.6.13-100.fc30.x86_64 
 :-----------:MMMdP-------    ---\   Uptime: 20 hours, 37 mins 
,------------:MMMd--------    ---:   Shell: zsh 
:------------:MMMd-------    .---:   Resolution: 1920x1080, 1920x1080 
:----    oNMMMMMMMMMNho     .----:   DE: Plasma 
:--     .+shhhMMMmhhy++   .------/   WM Theme: Sweet-Dark-transparent 
:-    -------:MMMd--------------:    CPU: Intel i7-9750H (12) @ 4.500GHz 
:-   --------/MMMd-------------;     Memory: 6167MiB / 15639MiB 
:-    ------/hMMMy------------:
:-- :dMNdhhdNMMNo------------;
:---:sdNMMMMNds:------------:
:------:://:-------------::
:---------------------://

Julia Information

Julia Version 1.4.1
Commit 381693d3df* (2020-04-14 17:20 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, skylake)

Support for concatenation (`Base.:*`)

Currently, the concatenation of two LaTeXStrings using the operator * yields a String, not a LaTeXString.

I propose to overload Base.:*, to the effect of something like

function Base.:*(lhs::LaTeXString, rhs::LaTeXString)
	return LaTeXString(lhs.s[1:end-1]*rhs.s[2:end])
end

Note that this example is not a valid implementation, since LaTeXStrings do not need to start and end with $, for example when they contain text.

defining * (concatenation) resulting in LaTeXString

Currently * for Tuple{LatexString, AbstractString} goes through the default method for AbstractStrings, returning a String.

I wonder if it would make sense to define

Base.:*(a::LaTeXString, b::AbstractString) = latexstring(a, b)

and similarly for the reversed order.

The issue came up when I was constructing plot labels in a function, eg

latexstring(L"$\alpha$", " for men")

which is of course OK but * may be more compact.

I think there is a bug in \hat, not sure if it from LaTeXStrings.jl

using Plots
using Distributions
using LaTeXStrings

dist = Normal(5, 2)
d = cdf.(dist, -2:0.1:10)
hlin1 = collect(1:75)
hlin2 = collect(75:121)

plot(d, label = "", width = 2, grid=false, color = "SteelBlue")
plot!(hlin1, zeros(75), width = 2, label = "", color = "black")
plot!(hlin2, ones(47), width = 2, label = "", color = "black")
plot!(75*ones(2), [0, 1], width = 2, label = "", color = "black")
annotate!([(77, 0.4, Plots.text(L"y_{t+k} = 75", 12, :black, :left))])
annotate!([(45, 0.15, Plots.text(L"\hat{F}_{t+k|t}", 12, "SteelBlue", :right))])

gives me
Captura de Tela 2020-12-30 às 23 35 02
but the same command in overleaf gives
Captura de Tela 2020-12-30 às 23 35 49

bug? Added an extra space

hi,

using Plots
using LaTeXStrings
p = plot(0:2,0:2, xlab = "xlabel: "*LaTeXString("\\gamma+\\alpha^2+1+\\alpha^2"), ylab = "ylabel: "*LaTeXString("1+\\alpha^2+1+\\alpha^2"))

I get the figure
QQ截图20200403185935

If try p = plot(0:2,0:2,xlab = "xlabel: "*LaTeXString("1+\\alpha^2+1+\\alpha^2")), I get
QQ截图20200403190853

Please keep attention on the xlabel and ylabel. It seems to exist an extra space in the label before first "+".

Is it a bug? Julia: Version 1.4.0 (2020-03-21); LaTeXStrings v1.1.0; Plots v0.29.4
Thank you!

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Package name LatexStrings

LatexStrings would be a better name for the package. I've just spent a few minutes trying to understand why the package won't download, because I mistyped the the exact casing.

Precompilation fails on 1.0

julia> using LaTeXStrings
[ Info: Precompiling LaTeXStrings [b964fa9f-0449-5b57-a5c2-d3ea65f4040f]
ERROR: LoadError: UndefVarError: start not defined
Stacktrace:
 [1] getproperty(::Module, ::Symbol) at .\sysimg.jl:13
 [2] top-level scope at none:0
 [3] include at .\boot.jl:317 [inlined]
 [4] include_relative(::Module, ::String) at .\loading.jl:1038
 [5] include(::Module, ::String) at .\sysimg.jl:29
 [6] top-level scope at none:2
 [7] eval at .\boot.jl:319 [inlined]
 [8] eval(::Expr) at .\client.jl:389
 [9] top-level scope at .\none:3
in expression starting at C:\Users\carsten\.julia\packages\LaTeXStrings\qycAf\src\LaTeXStrings.jl:62
ERROR: Failed to precompile LaTeXStrings [b964fa9f-0449-5b57-a5c2-d3ea65f4040f] to C:\Users\carsten\.julia\compiled\v1.0\LaTeXStrings\H4HGh.ji.
Stacktrace:
 [1] error(::String) at .\error.jl:33
 [2] macro expansion at .\logging.jl:313 [inlined]
 [3] compilecache(::Base.PkgId, ::String) at .\loading.jl:1184
 [4] macro expansion at .\logging.jl:311 [inlined]
 [5] _require(::Base.PkgId) at .\loading.jl:941
 [6] require(::Base.PkgId) at .\loading.jl:852
 [7] macro expansion at .\logging.jl:311 [inlined]
 [8] require(::Module, ::Symbol) at .\loading.jl:834

Seems to be due to the iterator interface change.

Because of this, PyPlot also won't precompile on 1.0:

julia> using PyPlot
[ Info: Precompiling PyPlot [d330b81b-6aea-500a-939a-2ce795aea3ee]
WARNING: could not import Base.start into PyCall
WARNING: could not import Base.done into PyCall
WARNING: could not import Base.next into PyCall
WARNING: could not import Base.mimewritable into PyPlot
ERROR: LoadError: UndefVarError: start not defined
Stacktrace:
 [1] getproperty(::Module, ::Symbol) at .\sysimg.jl:13
 [2] top-level scope at none:0
 [3] include at .\boot.jl:317 [inlined]
 [4] include_relative(::Module, ::String) at .\loading.jl:1038
 [5] include(::Module, ::String) at .\sysimg.jl:29
 [6] top-level scope at none:2
 [7] eval at .\boot.jl:319 [inlined]
 [8] eval(::Expr) at .\client.jl:389
 [9] top-level scope at .\none:3
in expression starting at C:\Users\carsten\.julia\packages\LaTeXStrings\qycAf\src\LaTeXStrings.jl:62
ERROR: LoadError: Failed to precompile LaTeXStrings [b964fa9f-0449-5b57-a5c2-d3ea65f4040f] to C:\Users\carsten\.julia\compiled\v1.0\LaTeXStrings\H4HGh.ji.
Stacktrace:
 [1] error(::String) at .\error.jl:33
 [2] macro expansion at .\logging.jl:313 [inlined]
 [3] compilecache(::Base.PkgId, ::String) at .\loading.jl:1184
 [4] _require(::Base.PkgId) at .\logging.jl:311
 [5] require(::Base.PkgId) at .\loading.jl:852
 [6] macro expansion at .\logging.jl:311 [inlined]
 [7] require(::Module, ::Symbol) at .\loading.jl:834
 [8] include at .\boot.jl:317 [inlined]
 [9] include_relative(::Module, ::String) at .\loading.jl:1038
 [10] include(::Module, ::String) at .\sysimg.jl:29
 [11] top-level scope at none:2
 [12] eval at .\boot.jl:319 [inlined]
 [13] eval(::Expr) at .\client.jl:389
 [14] top-level scope at .\none:3
in expression starting at C:\Users\carsten\.julia\packages\PyPlot\OJG1E\src\PyPlot.jl:295
ERROR: Failed to precompile PyPlot [d330b81b-6aea-500a-939a-2ce795aea3ee] to C:\Users\carsten\.julia\compiled\v1.0\PyPlot\oatAj.ji.
Stacktrace:
 [1] error(::String) at .\error.jl:33
 [2] macro expansion at .\logging.jl:313 [inlined]
 [3] compilecache(::Base.PkgId, ::String) at .\loading.jl:1184
 [4] _require(::Base.PkgId) at .\logging.jl:311
 [5] require(::Base.PkgId) at .\loading.jl:852
 [6] macro expansion at .\logging.jl:311 [inlined]
 [7] require(::Module, ::Symbol) at .\loading.jl:834

`\textrm` turned to math in plot

I am using LaTeXStrings.jl with Plots.jl to add labels to my curves. The label contains some formulae and some plain text description (see in the figure below). It seems that if I call the L"" directly, everything is good. However, when I used it in plot, the space and hyphen in text will be rendered as math, say, the space is missing and the hyphen is a minus.

Is it a bug or feature? Maybe I miss that in manual, but if I want the expected label, what should I do?

Snipaste_2021-06-06_20-56-10

BTW, I am using LaTeXStrings v1.2.1 and Plots v1.16.2 .

release version 1.3.1?

It seems that version 1.3.1 was not released (and that fixes method ambiguities that are causing Aqua tests to fail in other packages, apparently).

Display equations are not centerred in Jupyter notebooks

If in a Jupyter/IJulia notebook, we write a code cell with the following lines

$$
1 + 2 = 3
$$
"""

then the output is a math equation rendered by MathJax.
However, the equation is not centred in the output cell.

However, the following code

$$
1 + 2 = 3
$$

in a markdown cell results in an equation proper centred in the cell after it is rendered by Mathjax.

I am not sure if this a LaTeXStrings, IJulia or Jupyter problem though.

error and warning on windows

On julia 1.3 and 1.4, and windows 10, using LaTeXStrings with the gr backend in Plots

'latex' is not recognized as an internal or external command, operable program or batch file.

latex: failed to create a dvi file

This has appeared on a number of different systems.

The first seems to be solved by build LaTeXStrings.

The second seems to require dvips and it isn't clear to me how to install this on Windows. I assume it should get installed automatically as part of the build?

Incorrect escaping of `\` in tail position

The MWE is the following

julia> L"\\" # expected "\$\\\\\$"
L"$\$"

julia> L"$\\$" # works as expected
L"$\\$"

julia> L"$\\" # also works as expected
L"$\\"

julia> L"\\" # "eats" the last backslash
L"$\$"

julia> L"\\\\" # expected "\$\\\\\\\\\$" = L""
L"$\\$"

julia> println(L"\\$") # works as expected
$\\$$

(I guess this is simply a symptom of Julia escaping rules for strings.)

How to print a latexstring out

I am trying to print a latexstring using LatexStrings package:
println(L"gap at \gamma is: %$(gap) eV")
but get the following printed out:
$gap at \gamma is: 0.08904209804025498 eV$
which is not what I want. I know latexstring will work when plotting a figure using Plots . Why I cant print it in Latex style?

$$ appear when interpolating to axis label

I am trying to use LaTeXStrings to add special characters to the label of a plot. The following results can be obtained:

histogram!(xlabel=L"Test \alpha")

Result: image

All text is interpreted as an equation, which is not satisfactory.

histogram!(xlabel=L"\textrm{Test }\alpha")

Result: image

Possibly the best alternative, but the fonts are different from the fonts of the rest of the plot.

histogram!(xlabel="Test $(L"\alpha")")

Result:
image

This one looks very promising, because the special character (alpha) is rendered, and the fonts are not changed. However, the dollar signs appear. I could not get rid of them.

I am not sure if this an issue of the package or if there is a solution. I was able to find the following workaround:

string="$(L"Test \alpha")"
histogram!(xlabel=string[2:length(string)-1])

Result:
image

(unfortunately this option does not work to produce the Angstrom character (\AA))

Any thoughts? I could not find help anywhere else. I apologize already if this out of the scope of the issues.

Incorporating LaTexStrings.jl elsewhere

I had added support for the LaTex names to the more Swift-style string literal macro (in https://github.com/ScottPJones/StringUtils.jl/tree/spj/format) that I've been working on,
i.e. u"\{euro}" == "€",
and I just came across this nice package.
I was wondering if 1) it would be possible to have the u" " incorporate LaTexStrings.jl,
2) do you think it would be useful for people, and
3) if so, what do you think would be best for the syntax?

Something like the lines of: u"This is some latex: \l{1 + \alpha^2}" maybe?

text latex string

In Julia v1.4 I used this argument in a plot: ylabel=L"\large{\textit{V/m}}" and it worked fine.
I moved to Julia v1.6 and now it displays $V/m instead of V/m.
Do you have any hint?
Thanks

changing the font size with {\small} and \begin{small} \end{small}

Been having difficulty changing the font size of parts of the string and attempting to put it into the title of a plot with using Plots and either a pyplot or gr backend. The string is produced and do not know if the error is isolated in the figure plotting. A LaTeXString() or latexstring() or L""" """" produce the same error

julia> ll=LaTeXString("an equation;$ 2+3 \beta^3 }$ \n $\begin{small} \tau_4\end{small}$")
L"an equation;$ 2+3 \beta^3 }$
$\begin{small} \tau_4\end{small}$"

julia> plot([1,2,3,4],[1,2,3,4],title=ll)
Error showing value of type Plots.Plot{Plots.PyPlotBackend}:
ERROR: PyError (ccall(@pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, arg, C_NULL)) <type 'exceptions.ValueError'>

Tagging a new release for 1.0

This package causes the PyPlot installation to fail on 1.0. One has to use LaTeXStrings#master to get it to work. I think it would make sense to tag a new release soon.

Spaces removed in latex string

On Ubuntu 14.04, Julia v0.4.6, latexstring("a b") will remove the space character and eventually produce the LaTeX string "ab" on a matplotlib figure, is that by design? I couldn't find a solution, neither "\ " or ":" seemed to work, would you have an idea on how to fix this?

Many thanks,

Rendering LaTeX strings

Hi @stevengj,

I'm looking for a way of rendering LaTeXStrings into images (to be used with, e.g., Images.jl or Luxor.jl). Matplotlib seems to rely on dvipng and Ghostscript (and a LaTeX installation, of course 😄 ).

Can something like this be currently done with LaTeXStrings.jl? Thanks!

Problem displaying a LaTeXString using a $ symbol inside

Hi! I have found this problem with Pluto & LaTeXStrings:

Example:

image

Code:

### A Pluto.jl notebook ###
# v0.19.5

using Markdown
using InteractiveUtils

# ╔═╡ 0a05255c-e438-11ec-3566-77865b3fe6d8
using LaTeXStrings

# ╔═╡ 78067679-6a52-473f-bf96-657e0ca6d7f1
L"an equation: $1 + \alpha^2$"

# ╔═╡ 00000000-0000-0000-0000-000000000001
PLUTO_PROJECT_TOML_CONTENTS = """
[deps]
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"

[compat]
LaTeXStrings = "~1.3.0"
"""

# ╔═╡ 00000000-0000-0000-0000-000000000002
PLUTO_MANIFEST_TOML_CONTENTS = """
# This file is machine-generated - editing it directly is not advised

[[LaTeXStrings]]
git-tree-sha1 = "f2355693d6778a178ade15952b7ac47a4ff97996"
uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
version = "1.3.0"
"""

# ╔═╡ Cell order:
# ╠═0a05255c-e438-11ec-3566-77865b3fe6d8
# ╠═78067679-6a52-473f-bf96-657e0ca6d7f1
# ╟─00000000-0000-0000-0000-000000000001
# ╟─00000000-0000-0000-0000-000000000002

[PkgEval] LaTeXStrings may have a testing issue on Julia 0.3 (2014-11-06)

PackageEvaluator.jl is a script that runs nightly. It attempts to load all Julia packages and run their tests (if available) on both the stable version of Julia (0.3) and the nightly build of the unstable version (0.4). The results of this script are used to generate a package listing enhanced with testing results.

On Julia 0.3

  • On 2014-11-05 the testing status was Tests pass.
  • On 2014-11-06 the testing status changed to Package doesn't load.

Tests pass. means that PackageEvaluator found the tests for your package, executed them, and they all passed.

Package doesn't load. means that PackageEvaluator did not find tests for your package. Additionally, trying to load your package with using failed.

This issue was filed because your testing status became worse. No additional issues will be filed if your package remains in this state, and no issue will be filed if it improves. If you'd like to opt-out of these status-change messages, reply to this message saying you'd like to and @IainNZ will add an exception. If you'd like to discuss PackageEvaluator.jl please file an issue at the repository. For example, your package may be untestable on the test machine due to a dependency - an exception can be added.

Test log:

>>> 'Pkg.add("LaTeXStrings")' log
INFO: Installing LaTeXStrings v0.1.1
INFO: Package database updated
INFO: METADATA is out-of-date a you may not have the latest version of LaTeXStrings
INFO: Use `Pkg.update()` to get the latest versions of your packages

>>> 'using LaTeXStrings' log
Julia Version 0.3.1
Commit c03f413* (2014-09-21 21:30 UTC)
Platform Info:
  System: Linux (x86_64-unknown-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

ERROR: Compat not found
 in require at loading.jl:47
 in include at ./boot.jl:245
 in include_from_node1 at ./loading.jl:128
 in reload_path at loading.jl:152
 in _require at loading.jl:67
 in require at loading.jl:51
 in include at ./boot.jl:245
 in include_from_node1 at loading.jl:128
 in process_options at ./client.jl:285
 in _start at ./client.jl:354
 in _start_3B_1712 at /home/idunning/julia03/usr/bin/../lib/julia/sys.so
while loading /home/idunning/pkgtest/.julia/v0.3/LaTeXStrings/src/LaTeXStrings.jl, in expression starting on line 4
while loading /home/idunning/pkgtest/.julia/v0.3/LaTeXStrings/testusing.jl, in expression starting on line 2

>>> test log
no tests to run
>>> end of log

Escaping $ to interpolate variables in L"..."

Would it make sense (or would it be even possible) to allow "escaping" $, either with a double $$ or something else, to allow interpolation in L"..." strings? It would be convenient instead of having to fall back to using latexstring and needing to escape every $ and \.

Latex not rendering with PyPlot v2.3.2, Julia v0.5.2,

Hi there, great package.

Any idea why this doesn't render properly:

  using LaTeXStrings
  using Plots
  pyplot()
  plot(0:1,0:1,annotations=(0.5,0.5, L"x_l"))

Though the underscore appears correctly, the font is not standard maths LaTeX. I have updated all packages.

Do you know is this a problem with PyPlot, Plots or your package?

Thanks,
Art

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.