@@ -1700,7 +1700,6 @@ def names(elt):
1700
1700
csname = expr .split ("{" , 1 )[0 ]
1701
1701
err = (csname + "" .join ("{%s}" % name for name in names (args ))
1702
1702
if expr == csname else expr )
1703
- print (csname , args , err )
1704
1703
return csname - (args | Error (f"Expected { err } " ))
1705
1704
1706
1705
@@ -1871,7 +1870,6 @@ def csnames(group, names):
1871
1870
p .required_group = Forward ()
1872
1871
p .optional_group = Forward ()
1873
1872
p .token = Forward ()
1874
- p .substack = Forward ()
1875
1873
1876
1874
set_names_and_parse_actions () # for mutually recursive definitions.
1877
1875
@@ -1917,6 +1915,10 @@ def csnames(group, names):
1917
1915
1918
1916
p .text = cmd (r"\text" , QuotedString ('{' , '\\ ' , endQuoteChar = "}" ))
1919
1917
1918
+ p .substack = cmd (r"\substack" , "{" +
1919
+ delimited_list (OneOrMore (p .token ), delim = "\\ " ,
1920
+ combine = False )("parts" ) + "}" )
1921
+
1920
1922
p .subsuper = (
1921
1923
(Optional (p .placeable )("nucleus" )
1922
1924
+ OneOrMore (oneOf (["_" , "^" ]) - p .placeable )("subsuper" )
@@ -1935,9 +1937,6 @@ def csnames(group, names):
1935
1937
1936
1938
p .operatorname = cmd (r"\operatorname" , "{" + ZeroOrMore (p .simple )("name" ) + "}" )
1937
1939
1938
- p .substack <<= cmd (
1939
- r"\substack" , "{" + delimited_list (OneOrMore (p .token ), delim = "\\ \\ " , combine = True )("parts" )+ "}" )
1940
-
1941
1940
p .placeable <<= (
1942
1941
p .accent # Must be before symbol as all accents are symbols
1943
1942
| p .symbol # Must be second to catch all named symbols and single
@@ -1953,8 +1952,8 @@ def csnames(group, names):
1953
1952
| p .underset
1954
1953
| p .sqrt
1955
1954
| p .overline
1956
- | p .substack
1957
1955
| p .text
1956
+ | p .substack
1958
1957
)
1959
1958
1960
1959
p .auto_delim <<= (
@@ -1977,7 +1976,6 @@ def csnames(group, names):
1977
1976
1978
1977
# To add space to nucleus operators after sub/superscripts
1979
1978
self ._in_subscript_or_superscript = False
1980
- self .p = p
1981
1979
1982
1980
def parse (self , s , fonts_object , fontsize , dpi ):
1983
1981
"""
@@ -2606,17 +2604,24 @@ def auto_delim(self, s, loc, toks):
2606
2604
toks ["right" ])
2607
2605
2608
2606
def substack (self , s , loc , toks ):
2609
- print (list (toks .keys ()))
2610
- print (toks ["parts" ])
2611
- parts = toks ["parts" ].split ("\\ \\ " )
2612
- print (parts )
2607
+ parts = toks ["parts" ]
2613
2608
state = self .get_state ()
2614
2609
thickness = state .get_current_underline_thickness ()
2615
2610
vlist = []
2616
2611
2617
- max_width = max (map (lambda c : c .width , parts ))
2612
+ p = [[]]
2613
+ # Checking idle kern value as whitespace to
2614
+ # determine line break for multiple values
2615
+ for b in parts :
2616
+ if isinstance (b , Kern ):
2617
+ p .append ([])
2618
+ else :
2619
+ p [- 1 ].append (b )
2620
+
2621
+ hlist = [Hlist (k ) for k in p ]
2622
+ max_width = max (map (lambda c : c .width , hlist ))
2618
2623
2619
- for sub in parts :
2624
+ for sub in hlist :
2620
2625
cp = HCentered ([sub ])
2621
2626
cp .hpack (max_width , 'exactly' )
2622
2627
vlist .append (cp )
0 commit comments