[latex3-commits] [git/LaTeX3-latex3-latex3] master: xbox: First pass on minipage (77d4c2d01)
Joseph Wright
joseph.wright at morningstar2.co.uk
Tue Aug 25 15:17:50 CEST 2020
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/77d4c2d01ffdcf2b9a3f0a1bc9ad2c979a147487
>---------------------------------------------------------------
commit 77d4c2d01ffdcf2b9a3f0a1bc9ad2c979a147487
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Tue Aug 25 14:17:50 2020 +0100
xbox: First pass on minipage
This one is tricky: there is a lot of 'LaTeX2e galley stuff'
that for the experiments here we presumably have to keep.
>---------------------------------------------------------------
77d4c2d01ffdcf2b9a3f0a1bc9ad2c979a147487
l3trial/xbox/xbox.dtx | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 94 insertions(+), 1 deletion(-)
diff --git a/l3trial/xbox/xbox.dtx b/l3trial/xbox/xbox.dtx
index 0d8916821..42029aa7b 100644
--- a/l3trial/xbox/xbox.dtx
+++ b/l3trial/xbox/xbox.dtx
@@ -111,6 +111,24 @@
% and if neither are given is vertically centered.
% \end{function}
%
+% \begin{function}{minipage}
+% \begin{syntax}
+% \cs{minipage}\{lrbox\}\oarg{position}\oarg{height}\oarg{inner position}\marg{width}
+% \meta{content}
+% \cs{end}\{minipage\}
+% \end{syntax}
+% The environment form of \cs{parbox} taking the same arguments. In addition
+% to the setup carried out by \cs{parbox}, the \env{minipage} environment
+% also
+% \begin{itemize}
+% \item Sets \cs{textwidth} and \cs{columnwidth} the the \meta{width}
+% \item Redefines footnotes as described in the \LaTeXe{} documentation
+% (command names are unchanged)
+% \item Resets list depth to zero
+% \item Sets the \LaTeXe{} \cs{@minipage} flag
+% \end{itemize}
+% \end{function}
+%
% \begin{function}{\parbox}
% \begin{syntax}
% \cs{parbox}\oarg{position}\oarg{height}\oarg{inner position}\marg{width}\marg{content}
@@ -824,7 +842,6 @@
% \begin{macro}{\@@_parbox_vcenter:n}
% \begin{macro}{\@@_parbox_vcenter_to_ht:nn}
% \begin{macro}{\@@_parbox_vcenter:nn}
-% Here, using a coffin is the easiest way to pull off the alignment.
% We need to include the \LaTeXe{} command \tn{@parboxrestore} to get the
% documented behavior of the galley.
% \begin{macrocode}
@@ -909,6 +926,65 @@
% \end{macro}
% \end{macro}
%
+% \begin{macro}{\xbox_minipage_begin:n}
+% \begin{macro}{\@@_minipage_begin:}
+% \begin{macro}{\xbox_minipage_end:nn}
+% \begin{macro}{\xbox_minipage_end:nnnn}
+% \begin{macro}{\@@_minipage_end:}
+% \begin{macrocode}
+\cs_new_protected:Npn \xbox_minipage_begin:n #1
+ {
+ \vbox_set:Nw \l_@@_internal_box
+ \dim_set:Nn \hsize {#1}
+ \dim_set_eq:NN \textwidth \hsize
+ \dim_set_eq:NN \columnwidth \hsize
+ \@parboxrestore
+ \@@_minipage_begin:
+ \@minipagerestore
+ \@setminipage
+ }
+\cs_new_protected:Npn \@@_minipage_begin:
+ {
+ \cs_set_nopar:Npn \@mpfn { mpfootnote }
+ \cs_set_nopar:Npn \thempfn { \thempfootnote }
+ \int_zero:N \c at mpfootnote
+ \cs_set_eq:NN \@footnotetext \@mpfootnotetext
+ \cs_set_eq:NN \@listdepth \@mplistdepth
+ \int_zero:N \@mplistdepth
+ }
+\cs_new_protected:Npn \xbox_minipage_end:nn #1#2
+ {
+ \@@_minipage_end:
+ \xbox_parbox_to_wd:nnn {#1} {#2}
+ { \vbox_unpack_drop:N \l_@@_internal_box }
+ }
+\cs_new_protected:Npn \xbox_minipage_end:nnnn #1#2#3#4
+ {
+ \@@_minipage_end:
+ \xbox_parbox_to_wd:nnnnn {#1} {#2} {#3} {#4}
+ { \vbox_unpack_drop:N \l_@@_internal_box }
+ }
+\cs_new_protected:Npn \@@_minipage_end:
+ {
+ \par
+ \tex_unskip:D
+ \box_if_empty:NF \@mpfootins
+ {
+ \skip_vertical:n { \tex_skip:D \@mpfootins }
+ \color_ensure_current:
+ \footnoterule
+ \box_unpack_drop:N \@mpfootins
+ }
+ \@minipagefalse
+ \vbox_set_end:
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
% \begin{macro}{\xbox_raise:nn}
% \begin{macro}{\xbox_raise_with_ht:nnn}
% \begin{macro}{\xbox_raise_with_ht_and_dp:nnnn}
@@ -1210,6 +1286,23 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{environment}{minipage}
+% The environment form of \cs{parbox}: we get to show off \pkg{xparse}'s
+% ability to use arguments at the end of an environment.
+% \begin{macrocode}
+\RenewDocumentEnvironment { minipage } { O { c } o O {#1} m }
+ {
+ \mode_leave_vertical:
+ \xbox_minipage_begin:n {#4}
+ }
+ {
+ \IfNoValueTF {#2}
+ { \xbox_minipage_end:nn {#4} {#1} }
+ { \xbox_minipage_end:nnnn {#4} {#2} {#1} {#3} }
+ }
+% \end{macrocode}
+% \end{environment}
+%
% \begin{macro}{\parbox}
% At this level, a \cs{parbox} is quite easy to handle.
% \begin{macrocode}
More information about the latex3-commits
mailing list.