[latex3-commits] [git/LaTeX3-latex3-latex3] master: xbox: Add \underline (8ff917776)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Aug 25 17:16:37 CEST 2020


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/8ff917776ef566cf8ba62ee4c866c65a597dc6b2

>---------------------------------------------------------------

commit 8ff917776ef566cf8ba62ee4c866c65a597dc6b2
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Aug 25 16:16:37 2020 +0100

    xbox: Add \underline
    
    In text mode, not math mode is used at all, so
    I've chosen to stick to \fboxsep/\fboxrule.


>---------------------------------------------------------------

8ff917776ef566cf8ba62ee4c866c65a597dc6b2
 l3trial/xbox/xbox.dtx | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/l3trial/xbox/xbox.dtx b/l3trial/xbox/xbox.dtx
index e4bfb5a58..42aae2adc 100644
--- a/l3trial/xbox/xbox.dtx
+++ b/l3trial/xbox/xbox.dtx
@@ -175,6 +175,15 @@
 %   the typeset \meta{content}.
 % \end{function}
 %
+% \begin{function}{\underline}
+%   \begin{syntax}
+%     \cs{underline}\marg{content}
+%   \end{syntax}
+%   In text mode, inserts the \meta{content} in a horizontal box and underlines
+%   it with a rule of width \cs{fboxrule} and separation \cs{fboxsep}. In math
+%   mode, uses the \TeX{} math mode primitive to directly underline content.
+% \end{function}
+%
 % \section{Typesetting material in frames}
 %
 % \begin{variable}{\fboxrule}
@@ -509,6 +518,19 @@
 %   ( \meta{content} )$. See also \cs{hbox_frame:nnn}.
 % \end{function}
 %
+% \begin{function}{\hbox_underline:nnn, \hbox_underline:nVV}
+%   \begin{syntax}
+%     \cs{hbox_underline:nnn} \Arg{content} \Arg{thickness} \Arg{border}
+%   \end{syntax}
+%   Inserts the \meta{content} in a horizontal box and underlines
+%   with a rule of \meta{thickness}. A \meta{border} is left between the
+%   \meta{content} and the frame. The frame will overprint any part of the
+%   \meta{content} which lies outside of the bounding box at natural size
+%   (\emph{i.e.}~the frame is printed \enquote{after} the \meta{content}).
+%   The apparent size of the inserted box includes the frame and the border,
+%   this affects only the depth (contrast with \cs{hbox_frame:nnn}).
+% \end{function}
+%
 % \begin{function}{\hbox_line_left:n, \hbox_line_center:n, \hbox_line_right:n}
 %   \begin{syntax}
 %     \cs{hbox_line_left:n} \Arg{content}
@@ -1147,6 +1169,41 @@
 % \end{macro}
 % \end{macro}
 %
+% \begin{macro}{\hbox_underline:nnn, \hbox_frame:nVV}
+% \begin{macro}{\@@_underline:nnn, \@@_underline:ffn}
+%   Much like framing, but with only one line.
+%    \begin{macrocode}
+\cs_new_protected:Npn \hbox_underline:nnn #1#2#3
+  { \@@_underline:ffn { \dim_eval:n {#2} } { \dim_eval:n {#3} } {#1} }
+\cs_generate_variant:Nn \hbox_underline:nnn { nVV }
+\cs_new_protected:Npn \@@_underline:nnn #1#2#3
+  {
+    \group_begin:
+      \hbox_set:Nn \l_@@_internal_box {#3}
+      \hbox:n
+        {
+          \box_use:N \l_@@_internal_box
+          \kern_horizontal:n { -\box_wd:N \l_@@_internal_box }
+          \box_move_down:nn { \box_dp:N \l_@@_internal_box + #2 + #1 }
+            {
+              \vbox:n
+                {
+                  \hbox:n
+                    {
+                      \kern_horizontal:n
+                        { \box_wd:N \l_@@_internal_box }
+                    }
+                   \rule_horizontal:nn {#1} { \c_zero_dim }
+                }
+            }
+        }
+    \group_end:
+  }
+\cs_generate_variant:Nn \@@_underline:nnn { ff }
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
 % \begin{macro}{\hbox_line_left:n, \hbox_line_center:n, \hbox_line_right:n}
 %   Necessary to implement the \cs{\ldots line} commands.
 %    \begin{macrocode}
@@ -1347,6 +1404,19 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\underline}
+%   In text mode, this is like \cs{framebox}, in math mode there is a
+%   primitive (which ideally needs a new name).
+%    \begin{macrocode}
+\RenewDocumentCommand \underline { m }
+  {
+    \mode_if_math:TF
+      { \tex_underline:D {#1} }
+      { \xbox_underline:nVV {#1} \fboxrule \fboxsep }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsection{Storing boxed material}
 %
 % \begin{macro}{\newsavebox}





More information about the latex3-commits mailing list.