Skip to content

Commit

Permalink
Patch restricted horizontal again (#2232)
Browse files Browse the repository at this point in the history
* bind T_MATH in proper order

* minipage and \parbox use vertical mode

* Enhanced test case for vertical mode

* Made testcase more compact (and readable)
  • Loading branch information
brucemiller authored Oct 13, 2023
1 parent 91b5a4f commit 28e1985
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 127 deletions.
2 changes: 2 additions & 0 deletions lib/LaTeXML/Package/LaTeX.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -4852,6 +4852,7 @@ DefConstructor('\parbox[] OptionalUndigested OptionalUndigested {Dimension} VBox
mode => 'text', bounded => 1,
robust => 1,
beforeDigest => sub {
reenterTextMode(1); # actually vertical mode!
AssignRegister('\hsize' => $_[4]);
Let('\\\\', '\lx@parboxnewline'); });
DefMacroI('\@parboxrestore', undef, Tokens());
Expand All @@ -4873,6 +4874,7 @@ DefEnvironment('{minipage}[][][]{Dimension}', sub {
width => $_[4],
vattach => translateAttachment($_[1])); },
beforeDigest => sub {
reenterTextMode(1); # actually vertical mode!
Digest(T_CS('\@minipagetrue'));
AssignRegister('\hsize' => $_[4]);
# this conflicts (& not needed?) with insertBlock
Expand Down
7 changes: 5 additions & 2 deletions lib/LaTeXML/Package/TeX.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -3813,7 +3813,10 @@ DefPrimitive('\setlanguage Number', undef);
#======================================================================
# Decide whether we're going into or out of math, inline or display.
Tag('ltx:XMText', autoOpen => 1, autoClose => 1);
DefPrimitiveI(T_MATH, undef, sub {
# This really should be T_MATH
# and it should (or not) check for a second $ only if not in restricted horizontal mode!
# (and then all the \@dollar@in@(text|math|normal)mode defns would not be needed.
DefPrimitiveI('\@dollar@in@normalmode', undef, sub {
my ($stomach) = @_;
my $gullet = $stomach->getGullet;
my $mode = LookupValue('MODE');
Expand All @@ -3839,7 +3842,7 @@ DefPrimitiveI(T_MATH, undef, sub {
$op = '\@@BEGINDISPLAYMATH'; }
$stomach->invokeToken(T_CS($op)) if $op; });
# Let this be the default, conventional $
Let(T_CS('\@dollar@in@normalmode'), T_MATH);
Let(T_MATH, T_CS('\@dollar@in@normalmode'));

# Effectively these are the math hooks, redefine these to do what you want with math?
DefConstructorI('\@@BEGINDISPLAYMATH', undef,
Expand Down
Binary file modified t/digestion/dollar.pdf
Binary file not shown.
44 changes: 28 additions & 16 deletions t/digestion/dollar.tex
Original file line number Diff line number Diff line change
@@ -1,37 +1,49 @@
\documentclass{article}
\begin{document}

\hbox{text $math$ text}
\hbox{t $m$ t}

\hbox{text $$alsotext$$ text}
\hbox{t $$t$$ t}

Footnote\footnote{text $math$ text}
Another\footnote{text $$displayedmath$$ text}
Footnote\footnote{t $m$ t}
Another\footnote{t $$m$$ t}

\begin{minipage}{3in}
t $$m$$ t
\end{minipage}

\hbox{\begin{minipage}{3in}
t $$m$$ t
\end{minipage}}

\parbox{3in}{t $$m$$ t}

\hbox{\parbox{3in}{t $$m$$ t}}

Note that dollar inside equation, etc.~fails.
% \[ math {\rm $text$ } math \]
% \[ m {\rm $t$ } m \]

% \[ math $$math$$ math \]
% \[ m $$m$$ m \]

\mbox{text $math$ text}
\mbox{t $m$ t}

\mbox{text $$alsotext$$ text}
\mbox{t $$t$$ t}

\[ a + \mbox{text $math$ text} + c \]
\[ a + \mbox{t $m$ t} + c \]

\[ a + \mbox{text $$alsotext$$ text} + c \]
\[ a + \mbox{t $$t$$ t} + c \]

\[ a + \makebox{text $math$ text} + c \]
\[ a + \makebox{t $m$ t} + c \]

\[ a + \makebox{text $$alsotext$$ text} + c \]
\[ a + \makebox{t $$t$$ t} + c \]

Base\raisebox{1em}{text $math$ text}
Base\raisebox{1em}{t $m$ t}

Base\raisebox{1em}{text $$alsotext$$ text}
Base\raisebox{1em}{t $$t$$ t}

Base\shortstack{text\\ $math$\\ text}
Base\shortstack{t\\ $m$\\ t}

Base\shortstack{text\\$$alsotext$$\\ text}
Base\shortstack{t\\$$t$$\\ t}


\end{document}
Expand Down
Loading

0 comments on commit 28e1985

Please sign in to comment.