File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 13
13
14
14
add_numbered_vertex! (g) = (add_vertex! (g); top = nv (g)) # returns the number of the new vertex
15
15
16
+ # latex treats # as a special character, so we have to escape it. See:
17
+ # https://github.com/sisl/TikzGraphs.jl/issues/12
18
+ latex_escape (s:: String ) = replace (s, " #" , " \\ #" )
19
+
16
20
" Convert the current node into a label"
17
21
function label (sym)
18
22
sym == :(^ ) && return " \\ textasciicircum" # TikzGraphs chokes on ^
19
23
20
- return string (" \\ texttt{" , sym, " }" )
24
+ return latex_escape ( string (" \\ texttt{" , sym, " }" ) )
21
25
end
22
26
23
27
Original file line number Diff line number Diff line change @@ -17,3 +17,10 @@ using Base.Test
17
17
t = @tree x^ 2 + y^ 2
18
18
@test length (t. labels) == 7
19
19
end
20
+
21
+ @testset " latex special characters" begin
22
+ # Test for issues with the characters present in julia's generated symbols
23
+ expr = Expr (Symbol (" ##271" ))
24
+ t = walk_tree (expr)
25
+ @test t. labels[1 ] == " \\ texttt{\\ #\\ #271}"
26
+ end
You can’t perform that action at this time.
0 commit comments