[latex3-commits] [git/LaTeX3-latex3-latex2e] gh152: calc support for \vspace (#152) (b90010ed)
Frank Mittelbach
frank.mittelbach at latex-project.org
Tue Apr 21 18:58:23 CEST 2020
Repository : https://github.com/latex3/latex2e
On branch : gh152
Link : https://github.com/latex3/latex2e/commit/b90010ed6328185022580fe056028466ebd70444
>---------------------------------------------------------------
commit b90010ed6328185022580fe056028466ebd70444
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date: Tue Apr 21 18:58:23 2020 +0200
calc support for \vspace (#152)
>---------------------------------------------------------------
b90010ed6328185022580fe056028466ebd70444
base/changes.txt | 2 +
base/doc/ltnews32.tex | 12 ++---
base/ltspace.dtx | 61 ++++++++++++++++++++--
.../tlb-latexrelease-rollback-003-often.luatex.tlg | 4 ++
.../tlb-latexrelease-rollback-003-often.tlg | 4 ++
.../tlb-latexrelease-rollback-003-often.xetex.tlg | 4 ++
base/testfiles/tlb-rollback-004-often.luatex.tlg | 2 +
base/testfiles/tlb-rollback-004-often.tlg | 2 +
base/testfiles/tlb-rollback-004-often.xetex.tlg | 2 +
required/tools/testfiles/github-0152.lvt | 8 +++
required/tools/testfiles/github-0152.tlg | 28 +++++++++-
11 files changed, 118 insertions(+), 11 deletions(-)
diff --git a/base/changes.txt b/base/changes.txt
index ec9ef21b..2060e9ea 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -2,6 +2,8 @@
* ltspace.dtx (subsection{Horizontal space (and breaks)}):
Support calc syntax with \hspace (gh/152)
+ (subsection{Vertical spacing}):
+ Support calc syntax with \vspace (gh/152)
2020-04-13 Frank Mittelbach <Frank.Mittelbach at latex-project.org>
diff --git a/base/doc/ltnews32.tex b/base/doc/ltnews32.tex
index 3bd05b9f..02229ac1 100644
--- a/base/doc/ltnews32.tex
+++ b/base/doc/ltnews32.tex
@@ -204,13 +204,13 @@ $2^{16}$, and this limitation has now been lifted.
\githubissue{124}
-\subsection{Support \pkg{calc} in \cs{hspace}}
+\subsection{Support \pkg{calc} in \cs{hspace} and \cs{vspace}}
-The \cs{hspace} command was implemented by passing its value directly
-to a \TeX{} primitive. As a result it was impossible to specify
-anything other than a simple dimension value in its argument. This has
-been changed, so that now \pkg{calc} syntax (as in other places) is also
-supported.
+The \cs{hspace} and \cs{vspace} commands simply passed their argument
+to a \TeX{} primitive to produce the necessary space. As a result it
+was impossible to specify anything other than a simple dimension value
+in the argument. This has been changed, so that now \pkg{calc} syntax
+(as in other places) is also supported with these commands.
%
\githubissue{152}
diff --git a/base/ltspace.dtx b/base/ltspace.dtx
index 33474815..b63f52d2 100644
--- a/base/ltspace.dtx
+++ b/base/ltspace.dtx
@@ -944,6 +944,7 @@
% \changes{v1.2m}{1996/01/20}{Made robust}
% \begin{macro}{\@vspace}
% \begin{macro}{\@vspacer}
+% \begin{macro}{\@vspace at calcify}
% \changes{v1.2f}{1995/05/25}
% {(CAR) macros modified to be more efficient}
% \changes{v1.2f}{1995/05/25}{(CAR) \cs{@restorepar} added to avoid
@@ -959,14 +960,29 @@
% \end{itemize}
% \begin{macrocode}
\DeclareRobustCommand\vspace{\@ifstar\@vspacer\@vspace}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</2ekernel>
+%<*2ekernel|latexrelease>
+%<latexrelease>\IncludeInRelease{2020/10/01}%
+%<latexrelease> {\@vspace}{Support calc in \vspace}%
+% \end{macrocode}
+% We support calc syntax in the argument and therfore use \cs{setlength}.
+% \changes{v1.3m}{2020/04/21}{Support calc syntax (gh/152)}
+% \begin{macrocode}
+\def\@vspace at calcify#1{\begingroup\setlength\skip@{#1}\vskip\skip@\endgroup}
+% \end{macrocode}
+%
+% \begin{macrocode}
\def\@vspace #1{%
\ifvmode
- \vskip #1
+ \@vspace at calcify{#1}%
\vskip\z at skip
\else
\@bsphack
\vadjust{\@restorepar
- \vskip #1
+ \@vspace at calcify{#1}%
\vskip\z at skip
}%
\@esphack
@@ -979,7 +995,7 @@
\dimen@\prevdepth
\hrule \@height\z@
\nobreak
- \vskip #1
+ \@vspace at calcify{#1}%
\vskip\z at skip
\prevdepth\dimen@
\else
@@ -987,10 +1003,47 @@
\vadjust{\@restorepar
\hrule \@height\z@
\nobreak
- \vskip #1
+ \@vspace at calcify{#1}%
\vskip\z at skip}%
\@esphack
\fi}
+%</2ekernel|latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{0000/00/00}%
+%<latexrelease> {\@vspace}{Support calc in \vspace}%
+%<latexrelease>
+%<latexrelease>\let\@vspace at calcify\@undefined
+%<latexrelease>\def\@vspace #1{%
+%<latexrelease> \ifvmode
+%<latexrelease> \vskip #1
+%<latexrelease> \vskip\z at skip
+%<latexrelease> \else
+%<latexrelease> \@bsphack
+%<latexrelease> \vadjust{\@restorepar
+%<latexrelease> \vskip #1
+%<latexrelease> \vskip\z at skip
+%<latexrelease> }%
+%<latexrelease> \@esphack
+%<latexrelease> \fi}
+%<latexrelease>\def\@vspacer#1{%
+%<latexrelease> \ifvmode
+%<latexrelease> \dimen@\prevdepth
+%<latexrelease> \hrule \@height\z@
+%<latexrelease> \nobreak
+%<latexrelease> \vskip #1
+%<latexrelease> \vskip\z at skip
+%<latexrelease> \prevdepth\dimen@
+%<latexrelease> \else
+%<latexrelease> \@bsphack
+%<latexrelease> \vadjust{\@restorepar
+%<latexrelease> \hrule \@height\z@
+%<latexrelease> \nobreak
+%<latexrelease> \vskip #1
+%<latexrelease> \vskip\z at skip}%
+%<latexrelease> \@esphack
+%<latexrelease> \fi}
+%<latexrelease>\EndIncludeInRelease
+%<*2ekernel>
% \end{macrocode}
% \end{macro}
% \end{macro}
diff --git a/base/testfiles/tlb-latexrelease-rollback-003-often.luatex.tlg b/base/testfiles/tlb-latexrelease-rollback-003-often.luatex.tlg
index dbd88b9f..86edf7d6 100644
--- a/base/testfiles/tlb-latexrelease-rollback-003-often.luatex.tlg
+++ b/base/testfiles/tlb-latexrelease-rollback-003-often.luatex.tlg
@@ -165,6 +165,8 @@ Skipping: [....-..-..] hyphenation after space hack on input line ....
Applying: [....-..-..] hyphenation after space hack on input line ....
Skipping: [....-..-..] \addpenalty on input line ....
Applying: [....-..-..] \addpenalty on input line ....
+Skipping: [....-..-..] Support calc in \vspace on input line ....
+Applying: [....-..-..] Support calc in \vspace on input line ....
Skipping: [....-..-..] Space after \@ on input line ....
Applying: [....-..-..] Space after \@ on input line ....
Skipping: [....-..-..] Support calc with \hspace on input line ....
@@ -524,6 +526,8 @@ Applying: [....-..-..] hyphenation after space hack on input line ....
Already applied: [....-..-..] hyphenation after space hack on input line ...
Applying: [....-..-..] \addpenalty on input line ....
Already applied: [....-..-..] \addpenalty on input line ....
+Skipping: [....-..-..] Support calc in \vspace on input line ....
+Applying: [....-..-..] Support calc in \vspace on input line ....
Applying: [....-..-..] Space after \@ on input line ....
Already applied: [....-..-..] Space after \@ on input line ....
Skipping: [....-..-..] Support calc with \hspace on input line ....
diff --git a/base/testfiles/tlb-latexrelease-rollback-003-often.tlg b/base/testfiles/tlb-latexrelease-rollback-003-often.tlg
index 4bfcce0a..445c0b7e 100644
--- a/base/testfiles/tlb-latexrelease-rollback-003-often.tlg
+++ b/base/testfiles/tlb-latexrelease-rollback-003-often.tlg
@@ -163,6 +163,8 @@ Skipping: [....-..-..] hyphenation after space hack on input line ....
Applying: [....-..-..] hyphenation after space hack on input line ....
Skipping: [....-..-..] \addpenalty on input line ....
Applying: [....-..-..] \addpenalty on input line ....
+Skipping: [....-..-..] Support calc in \vspace on input line ....
+Applying: [....-..-..] Support calc in \vspace on input line ....
Skipping: [....-..-..] Space after \@ on input line ....
Applying: [....-..-..] Space after \@ on input line ....
Skipping: [....-..-..] Support calc with \hspace on input line ....
@@ -516,6 +518,8 @@ Applying: [....-..-..] hyphenation after space hack on input line ....
Already applied: [....-..-..] hyphenation after space hack on input line ...
Applying: [....-..-..] \addpenalty on input line ....
Already applied: [....-..-..] \addpenalty on input line ....
+Skipping: [....-..-..] Support calc in \vspace on input line ....
+Applying: [....-..-..] Support calc in \vspace on input line ....
Applying: [....-..-..] Space after \@ on input line ....
Already applied: [....-..-..] Space after \@ on input line ....
Skipping: [....-..-..] Support calc with \hspace on input line ....
diff --git a/base/testfiles/tlb-latexrelease-rollback-003-often.xetex.tlg b/base/testfiles/tlb-latexrelease-rollback-003-often.xetex.tlg
index 0c0ac338..6c6d94f9 100644
--- a/base/testfiles/tlb-latexrelease-rollback-003-often.xetex.tlg
+++ b/base/testfiles/tlb-latexrelease-rollback-003-often.xetex.tlg
@@ -163,6 +163,8 @@ Skipping: [....-..-..] hyphenation after space hack on input line ....
Applying: [....-..-..] hyphenation after space hack on input line ....
Skipping: [....-..-..] \addpenalty on input line ....
Applying: [....-..-..] \addpenalty on input line ....
+Skipping: [....-..-..] Support calc in \vspace on input line ....
+Applying: [....-..-..] Support calc in \vspace on input line ....
Skipping: [....-..-..] Space after \@ on input line ....
Applying: [....-..-..] Space after \@ on input line ....
Skipping: [....-..-..] Support calc with \hspace on input line ....
@@ -525,6 +527,8 @@ Applying: [....-..-..] hyphenation after space hack on input line ....
Already applied: [....-..-..] hyphenation after space hack on input line ...
Applying: [....-..-..] \addpenalty on input line ....
Already applied: [....-..-..] \addpenalty on input line ....
+Skipping: [....-..-..] Support calc in \vspace on input line ....
+Applying: [....-..-..] Support calc in \vspace on input line ....
Applying: [....-..-..] Space after \@ on input line ....
Already applied: [....-..-..] Space after \@ on input line ....
Skipping: [....-..-..] Support calc with \hspace on input line ....
diff --git a/base/testfiles/tlb-rollback-004-often.luatex.tlg b/base/testfiles/tlb-rollback-004-often.luatex.tlg
index f6385798..cb5c52f4 100644
--- a/base/testfiles/tlb-rollback-004-often.luatex.tlg
+++ b/base/testfiles/tlb-rollback-004-often.luatex.tlg
@@ -262,6 +262,8 @@ Applying: [....-..-..] hyphenation after space hack on input line ....
Already applied: [....-..-..] hyphenation after space hack on input line ...
Applying: [....-..-..] \addpenalty on input line ....
Already applied: [....-..-..] \addpenalty on input line ....
+Skipping: [....-..-..] Support calc in \vspace on input line ....
+Applying: [....-..-..] Support calc in \vspace on input line ....
Applying: [....-..-..] Space after \@ on input line ....
Already applied: [....-..-..] Space after \@ on input line ....
Skipping: [....-..-..] Support calc with \hspace on input line ....
diff --git a/base/testfiles/tlb-rollback-004-often.tlg b/base/testfiles/tlb-rollback-004-often.tlg
index 634934b2..224e12f0 100644
--- a/base/testfiles/tlb-rollback-004-often.tlg
+++ b/base/testfiles/tlb-rollback-004-often.tlg
@@ -260,6 +260,8 @@ Applying: [....-..-..] hyphenation after space hack on input line ....
Already applied: [....-..-..] hyphenation after space hack on input line ...
Applying: [....-..-..] \addpenalty on input line ....
Already applied: [....-..-..] \addpenalty on input line ....
+Skipping: [....-..-..] Support calc in \vspace on input line ....
+Applying: [....-..-..] Support calc in \vspace on input line ....
Applying: [....-..-..] Space after \@ on input line ....
Already applied: [....-..-..] Space after \@ on input line ....
Skipping: [....-..-..] Support calc with \hspace on input line ....
diff --git a/base/testfiles/tlb-rollback-004-often.xetex.tlg b/base/testfiles/tlb-rollback-004-often.xetex.tlg
index b13140c2..bac4c567 100644
--- a/base/testfiles/tlb-rollback-004-often.xetex.tlg
+++ b/base/testfiles/tlb-rollback-004-often.xetex.tlg
@@ -260,6 +260,8 @@ Applying: [....-..-..] hyphenation after space hack on input line ....
Already applied: [....-..-..] hyphenation after space hack on input line ...
Applying: [....-..-..] \addpenalty on input line ....
Already applied: [....-..-..] \addpenalty on input line ....
+Skipping: [....-..-..] Support calc in \vspace on input line ....
+Applying: [....-..-..] Support calc in \vspace on input line ....
Applying: [....-..-..] Space after \@ on input line ....
Already applied: [....-..-..] Space after \@ on input line ....
Skipping: [....-..-..] Support calc with \hspace on input line ....
diff --git a/required/tools/testfiles/github-0152.lvt b/required/tools/testfiles/github-0152.lvt
index f3420e2c..216acddb 100644
--- a/required/tools/testfiles/github-0152.lvt
+++ b/required/tools/testfiles/github-0152.lvt
@@ -13,4 +13,12 @@
a\hspace{\widthof{some text}}b
+a
+\vspace{\widthof{some text}}
+b
+
+\vspace{3pt + 2pt}
+
+END
+
\end{document}
diff --git a/required/tools/testfiles/github-0152.tlg b/required/tools/testfiles/github-0152.tlg
index 5f660f90..00391596 100644
--- a/required/tools/testfiles/github-0152.tlg
+++ b/required/tools/testfiles/github-0152.tlg
@@ -9,7 +9,7 @@ Completed box being shipped out [1]
...\hbox(0.0+0.0)x345.0
..\glue 25.0
..\glue(\lineskip) 0.0
-..\vbox(550.0+0.0)x345.0, glue set 539.94232fil
+..\vbox(550.0+0.0)x345.0, glue set 468.39433fil
...\write-{}
...\glue(\topskip) 3.05556
...\hbox(6.94444+0.0)x345.0, glue set 276.88878fil
@@ -20,6 +20,32 @@ Completed box being shipped out [1]
....\penalty 10000
....\glue(\parfillskip) 0.0 plus 1.0fil
....\glue(\rightskip) 0.0
+...\glue(\parskip) 0.0 plus 1.0
+...\glue(\baselineskip) 5.05556
+...\hbox(6.94444+0.0)x345.0, glue set 316.11108fil
+....\hbox(0.0+0.0)x15.0
+....\OT1/cmr/m/n/10 a
+....\glue 3.33333 plus 1.66666 minus 1.11111
+....\penalty 10000
+....\glue 0.0
+....\OT1/cmr/m/n/10 b
+....\penalty 10000
+....\glue(\parfillskip) 0.0 plus 1.0fil
+....\glue(\rightskip) 0.0
+...\glue 42.55563
+...\glue 0.0
+...\glue 5.0
+...\glue 0.0
+...\glue(\parskip) 0.0 plus 1.0
+...\glue(\baselineskip) 5.16669
+...\hbox(6.83331+0.0)x345.0, glue set 308.05551fil
+....\hbox(0.0+0.0)x15.0
+....\OT1/cmr/m/n/10 E
+....\OT1/cmr/m/n/10 N
+....\OT1/cmr/m/n/10 D
+....\penalty 10000
+....\glue(\parfillskip) 0.0 plus 1.0fil
+....\glue(\rightskip) 0.0
...\glue 0.0 plus 1.0fil
...\glue 0.0
...\glue 0.0 plus 0.0001fil
More information about the latex3-commits
mailing list.