Skip to content

Commit

Permalink
Fix crystals latex
Browse files Browse the repository at this point in the history
  • Loading branch information
kwankyu committed Oct 5, 2024
1 parent 841298f commit 88edf1a
Showing 1 changed file with 40 additions and 22 deletions.
62 changes: 40 additions & 22 deletions src/sage/graphs/graph_latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1938,48 +1938,66 @@ def translate(p):
s += [str(round(el_color[edge][2], 4)), '}\n']
s += ['%\n']

# Create each vertex
# Create vertices
v = []
box = ''
used = False
for u in vertex_list:
s += ['\\Vertex[']
t = [r'\Vertex[']
# colors, shapes, sizes, labels/placement for 'Custom' style
if customized:
s += ['style={'] # begin style list
s += ['minimum size=', str(round(float(scale * v_size[u]), 4)),
t += ['style={'] # begin style list
t += ['minimum size=', str(round(float(scale * v_size[u]), 4)),
units, ',']
s += ['draw=', vertex_color_names[u], ',']
s += ['fill=', vertex_fill_color_names[u], ',']
t += ['draw=', vertex_color_names[u], ',']
t += ['fill=', vertex_fill_color_names[u], ',']
if vertex_labels:
s += ['text=', vertex_label_color_names[u], ',']
t += ['text=', vertex_label_color_names[u], ',']
if v_shape[u] == 'sphere':
s += ['shape=circle,shading=ball,line width=0pt,ball color=', vertex_color_names[u], ',']
t += ['shape=circle,shading=ball,line width=0pt,ball color=', vertex_color_names[u], ',']
else:
s += ['shape=', v_shape[u]]
s += ['},'] # end style list
t += ['shape=', v_shape[u]]
t += ['},'] # end style list
if vertex_labels:
if vl_placement[u] == 'center':
s += ['LabelOut=false,']
t += ['LabelOut=false,']
else:
s += ['LabelOut=true,']
s += ['Ldist=', str(round(float(scale * vl_placement[u][0]), 4)), units, ',']
s += ['Lpos=', str(round(float(vl_placement[u][1]), 4)), ','] # degrees, no units
t += ['LabelOut=true,']
t += ['Ldist=', str(round(float(scale * vl_placement[u][0]), 4)), units, ',']
t += ['Lpos=', str(round(float(vl_placement[u][1]), 4)), ','] # degrees, no units
else:
s += ['NoLabel,']
t += ['NoLabel,']

Check warning on line 1969 in src/sage/graphs/graph_latex.py

View check run for this annotation

Codecov / codecov/patch

src/sage/graphs/graph_latex.py#L1969

Added line #L1969 was not covered by tests
# vertex label information is available to all pre-built styles
# but may be ignored by the style, so not apparent
if vertex_labels or not customized:
if vertex_labels_math and not (isinstance(u, str) and u[0] == '$' and u[-1] == '$'):
lab = r'\hbox{$%s$}' % latex(u)
ltx = str(latex(u))
if '\\' in ltx: # complicated case; use \sbox
box = r'\sbox{\vertex}{$' + ltx + '$}'
lab = r'\usebox{\vertex}'
else:
lab = r'\hbox{$%s$}' % ltx
else:
lab = r'\hbox{%s}' % u
s += ['L=', lab, ',']
t += ['L=', lab, ',']
scaled_pos = translate(pos[u])
s += ['x=', str(round(float(scale * scaled_pos[0]), 4)), units, ',']
s += ['y=', str(round(float(scale * scaled_pos[1]), 4)), units]
s += [']']
s += ['{', prefix, str(index_of_vertex[u]), '}\n']
t += ['x=', str(round(float(scale * scaled_pos[0]), 4)), units, ',']
t += ['y=', str(round(float(scale * scaled_pos[1]), 4)), units]
t += [']']
t += ['{', prefix, str(index_of_vertex[u]), '}\n']
if box:
v += [box] + t
box = ''
used = True
else:
v += t
if used:
s += [r'\newsavebox{\vertex}' + '\n'] + v
else:
s += v
s += ['%\n']

# Create each edge or loop
# Create edges and loops
for e in self._graph.edges(sort=False):
edge = (e[0], e[1])
loop = e[0] == e[1]
Expand Down

0 comments on commit 88edf1a

Please sign in to comment.