diff options
author | Karl Berry <karl@freefriends.org> | 2013-04-23 22:17:44 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-04-23 22:17:44 +0000 |
commit | c0605257da4328774f6e42c1bcadefcac129f5aa (patch) | |
tree | 45647ed211a2b6b2e5b077287765d2c14782c813 /Master/texmf-dist | |
parent | ce96f93eee04e6c89a60b819a43ec27e85fce25e (diff) |
minibox (21apr13)
git-svn-id: svn://tug.org/texlive/trunk@30083 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/minibox/README | 5 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/minibox/minibox.pdf | bin | 120543 -> 165290 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/minibox/minibox.tex | 212 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/minibox/minibox.sty | 69 |
4 files changed, 232 insertions, 54 deletions
diff --git a/Master/texmf-dist/doc/latex/minibox/README b/Master/texmf-dist/doc/latex/minibox/README index b13ebcdc2f8..0cdc7b177fb 100644 --- a/Master/texmf-dist/doc/latex/minibox/README +++ b/Master/texmf-dist/doc/latex/minibox/README @@ -1,6 +1,6 @@ ___________________ The minibox package -v0.1 +v0.2 A small package to provide a convenient input syntax for boxes that don't break their text over lines automatically, @@ -9,6 +9,7 @@ the natural width of the maximum line width. \minibox{Some\\ broken\\ text} \minibox[c]{Centred\\ broken\\ text} + \minibox[ct]{Centred\\ aligned\\ top} Will Robertson -Copyright 2009 +Copyright 2009, 2013 diff --git a/Master/texmf-dist/doc/latex/minibox/minibox.pdf b/Master/texmf-dist/doc/latex/minibox/minibox.pdf Binary files differindex 7d208dd4d78..4c8e1232784 100644 --- a/Master/texmf-dist/doc/latex/minibox/minibox.pdf +++ b/Master/texmf-dist/doc/latex/minibox/minibox.pdf diff --git a/Master/texmf-dist/source/latex/minibox/minibox.tex b/Master/texmf-dist/source/latex/minibox/minibox.tex index 3cdfdf82247..ea87f738882 100644 --- a/Master/texmf-dist/source/latex/minibox/minibox.tex +++ b/Master/texmf-dist/source/latex/minibox/minibox.tex @@ -4,7 +4,7 @@ \begin{filecontents*}{README.txt} ___________________ The minibox package -v0.1 +v0.2 A small package to provide a convenient input syntax for boxes that don't break their text over lines automatically, @@ -13,26 +13,74 @@ the natural width of the maximum line width. \minibox{Some\\ broken\\ text} \minibox[c]{Centred\\ broken\\ text} + \minibox[ct]{Centred\\ aligned\\ top} Will Robertson -Copyright 2009 +Copyright 2009, 2013 \end{filecontents*} %%%%%%%%%1%%%%%%%%%2%%%%%%%%%3%%%%%%%%%4%%%%%%%%%5%%%%%%%%%6%%%%%%%%%7%%%%%%%%% -\begin{filecontents}{minibox.sty} -\ProvidesPackage{minibox}[2009/04/21 v0.1 - Another type of box.] - -% This is the simplest definition I can get away with. -% But it's not perfect; expect changes in the future. -\newcommand\minibox[2][l]{% - \begin{tabular}{@{}#1@{}} - #2 - \end{tabular}% -} - -\end{filecontents} +\begin{filecontents*}{minibox.sty} +% \begin{macrocode} +\RequirePackage{expl3} +\ProvidesExplPackage + {minibox} + {2013/04/20} + {0.2} + {Another type of box.} +% \end{macrocode} +% +% \begin{macrocode} +\bool_new:N \l_minibox_frame_bool +\keys_define:nn {minibox} + { + frame .choice: , + frame / true .code:n = { \bool_set_true:N \l_minibox_frame_bool } , + frame / false .code:n = { \bool_set_false:N \l_minibox_frame_bool } , + frame .default:n = { true } , + + l .code:n = { \tl_set:Nn \l_minibox_tabular_preamble_tl {l} } , + c .code:n = { \tl_set:Nn \l_minibox_tabular_preamble_tl {c} } , + r .code:n = { \tl_set:Nn \l_minibox_tabular_preamble_tl {r} } , + + t .code:n = { \tl_set:Nn \l_minibox_tabular_valign_tl {t} } , + m .code:n = { \tl_set:Nn \l_minibox_tabular_valign_tl {c} } , + b .code:n = { \tl_set:Nn \l_minibox_tabular_valign_tl {b} } , + + rule .dim_set:N = \l_minibox_rule_dim , + pad .dim_set:N = \l_minibox_pad_dim , + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new:Npn \miniboxsetup #1 { \keys_set:nn {minibox} {#1} } +\miniboxsetup {l,m,rule=\fboxrule,pad=\fboxsep} +% \end{macrocode} +% +% \begin{macrocode} +\newcommand\minibox[2][] + { + \group_begin: + \keys_set:nn {minibox} {#1} + \bool_if:NTF \l_minibox_frame_bool + { + \setlength\fboxrule{\l_minibox_rule_dim} + \setlength\fboxsep{\l_minibox_pad_dim} + \fbox + } + { \use:n } + { + \begin{tabular} + [\l_minibox_tabular_valign_tl] + { @{} \l_minibox_tabular_preamble_tl @{} } + #2 + \end{tabular} + } + \group_end: + } +% \end{macrocode} +\end{filecontents*} %%%%%%%%%1%%%%%%%%%2%%%%%%%%%3%%%%%%%%%4%%%%%%%%%5%%%%%%%%%6%%%%%%%%%7%%%%%%%%% @@ -56,17 +104,12 @@ Copyright 2009 \makeatletter -\documentclass{article} +\documentclass{ltxdoc} \usepackage[rm,medium]{titlesec} -\usepackage{bigfoot,xcolor} +\usepackage{xcolor,booktabs} \usepackage[colorlinks,linktocpage]{hyperref} -\usepackage{gmdoc} -\usepackage{gmverb} -\dekclubs -\stanzaskip=\bigskipamount -\CodeSpacesGrey \usepackage{tocloft,varwidth} \setcounter{tocdepth}{1} @@ -105,9 +148,7 @@ Copyright 2009 \maketitle -\part{User documentation} - -\section{The \cmd\minibox\ command} +\section{Introduction} It's sometimes useful to be able to stack text over lines in a small box; this is similar to paragraph text broken over lines, but @@ -120,8 +161,38 @@ This sort of thing is a little awkward in plain \TeX\ and \LaTeX. \begin{center} |\vbox{\hbox{abcd}\hbox{efg}\hbox{h}}|\par \end{center} + +\section{The command \cs{minibox}} + This package defines the \cmd\minibox\DescribeMacro{\minibox}\ command -to write this more conveniently. Here's an example: +to write this more conveniently separately lines with \verb"\\". +Various options are allowed to control the alignment and whether to frame the box, shown in Table~\ref{opt}. + +\begin{table} +\centering +\begin{tabular}{rl} +\toprule +\texttt{frame(=true)} & Has a frame \\ +\texttt{frame=false} & Has not a frame (default) \\ +\texttt{rule=}\meta{dim} & Thickness of the rule (default \the\fboxrule) \\ +\texttt{pad=}\meta{dim} & Space on the inside of the frame (default \the\fboxsep) \\ +\midrule +\texttt{l} & Left-aligned text (default) \\ +\texttt{c} & Centred text \\ +\texttt{r} & Right-aligned text \\ +\midrule +\texttt{b} & Align the box with the bottom line \\ +\texttt{m} & Vertically centre the box (default) \\ +\texttt{t} & Align the box with the top line \\ +\bottomrule +\end{tabular} +\caption{Optional arguments for the \cs{minibox} command.} +\label{opt} +\end{table} + +\subsection{Horizontal alignment of the text} +Here's an example adjusting the horizontal alignment. +\miniboxsetup{frame} \begin{center} \verb|\def\x{abcd\\efg\\h}| \def\x{abcd\\efg\\h} @@ -129,29 +200,92 @@ to write this more conveniently. Here's an example: \verb"\minibox{\x}" & \verb"\minibox[c]{\x}" & \verb"\minibox[r]{\x}" \\ -\fbox{\minibox{\x}} & -\fbox{\minibox[c]{\x}} & -\fbox{\minibox[r]{\x}} +\minibox{\x} & +\minibox[c]{\x} & +\minibox[r]{\x} +\end{tabular} +\end{center} + +\subsection{Vertical alignment of the box} +Here's an example adjusting the vertical alignment. +\begin{center} +\verb|\def\x{abcd\\efg\\h}| +\medskip + +\def\x{abcd\\efg\\h} +\begin{tabular}{ccc} +\verb"xyz\minibox{\x}" & +\verb"xyz\minibox[b]{\x}" & +\verb"xyz\minibox[t]{\x}" \\ +xyz\minibox{\x} & +xyz\minibox[b]{\x} & +xyz\minibox[t]{\x} +\end{tabular} +\end{center} + +\subsection{Framing your box} +The boxes which are showed in these examples are not displayed by default; use the \verb"frame" option to make them appear: +\miniboxsetup{frame=false} +\begin{center} +\verb|\def\x{abcd\\efg\\h}| +\medskip + +\def\x{abcd\\efg\\h} +\begin{tabular}{ccc} +\verb"\minibox{\x}" & +\verb"\minibox[frame]{\x}" & +\verb"\minibox[frame,rule=1pt,pad=0pt]{\x}" \\ +\minibox{\x} & +\minibox[frame]{\x} & +\minibox[frame,rule=1pt,pad=0pt]{\x} \\ +\end{tabular} +\end{center} +Negative values can be input for \texttt{pad}. +\begin{quote}\itshape +\LaTeX\ experts: while these padding and rule options are internally controlled by \cs{fboxsep} and \cs{fboxrule}, changing these variables will have no effect on \cs{minibox}'s behaviour. Use \cs{miniboxsetup} as described next to change these options globally. +\end{quote} + +\subsection{Setting options} + +Obviously, any combination of these options can be applied: +\begin{center} +\verb|\def\x{abcd\\efg\\h}| +\medskip + +\def\x{abcd\\efg\\h} +\begin{tabular}{ccc} +\verb"x\minibox[frame]{\x}" & +\verb"x\minibox[frame,c,b]{\x}" \\ +x\minibox[frame]{\x} & +x\minibox[frame,c,b]{\x} +\end{tabular} +\end{center} +\DescribeMacro{\miniboxsetup} +You can change the defaults of \cs{minibox} using this command. +\begin{center} +\verb|\def\x{abcd\\efg\\h}| +\medskip + +\def\x{abcd\\efg\\h} +\begin{tabular}{ccc} +& \verb"\miniboxsetup{frame,r}" \\ +\verb"\minibox{\x}" & +\verb"\minibox{\x}" \\ +\minibox{\x} & +\miniboxsetup{frame,r}\minibox{\x} \end{tabular} \end{center} -Note that all examples here have been framed with the \cmd\fbox\ command -to show the extent of the box; the output of \cmd\minibox\ itself does not have this border! -Actually, if you look (not too) closely, the \cmd\minibox\ output has a little more padding -than the |\vbox{\hbox{...}}| version; this will be rectified in a future release -of the package. +\subsection{Cautionary note, perhaps} -If you look at the source you'll see that the way \cmd\minibox\ command is -implemented lends itself to begin mis-used to input generic tabular material; -this is not the intention of the command, however, and any such usage may -break in future versions of this package. +If you look at the source you'll see that the way \cmd\minibox\ command is implemented lends itself to begin mis-used to input generic tabular material; this is not the intention of the command, however, and any such usage may break in future versions of this package. \section{Licence} This package is freely modifiable and distributable under the terms and conditions of the \LaTeX\ Project Public Licence, version 1.3c or greater (your choice). The latest version of this license is available at: \url{http://www.latex-project.org/lppl.txt}. This work is maintained by \textsc{Will Robertson}. -\clearpage +\newpage \part{Implementation} \parindent=0pt \DocInput{\pkgname.sty} diff --git a/Master/texmf-dist/tex/latex/minibox/minibox.sty b/Master/texmf-dist/tex/latex/minibox/minibox.sty index 55fa4220619..039620799e9 100644 --- a/Master/texmf-dist/tex/latex/minibox/minibox.sty +++ b/Master/texmf-dist/tex/latex/minibox/minibox.sty @@ -1,15 +1,58 @@ -%% LaTeX2e file `minibox.sty' -%% generated by the `filecontents' environment -%% from source `minibox' on 2009/04/22. -%% -\ProvidesPackage{minibox}[2009/04/21 v0.1 - Another type of box.] +% \begin{macrocode} +\RequirePackage{expl3} +\ProvidesExplPackage + {minibox} + {2013/04/20} + {0.2} + {Another type of box.} +% \end{macrocode} +% +% \begin{macrocode} +\bool_new:N \l_minibox_frame_bool +\keys_define:nn {minibox} + { + frame .choice: , + frame / true .code:n = { \bool_set_true:N \l_minibox_frame_bool } , + frame / false .code:n = { \bool_set_false:N \l_minibox_frame_bool } , + frame .default:n = { true } , -% This is the simplest definition I can get away with. -% Expect changes in the future. -\newcommand\minibox[2][l]{% - \begin{tabular}{@{}#1@{}} - #2 - \end{tabular}% -} + l .code:n = { \tl_set:Nn \l_minibox_tabular_preamble_tl {l} } , + c .code:n = { \tl_set:Nn \l_minibox_tabular_preamble_tl {c} } , + r .code:n = { \tl_set:Nn \l_minibox_tabular_preamble_tl {r} } , + t .code:n = { \tl_set:Nn \l_minibox_tabular_valign_tl {t} } , + m .code:n = { \tl_set:Nn \l_minibox_tabular_valign_tl {c} } , + b .code:n = { \tl_set:Nn \l_minibox_tabular_valign_tl {b} } , + + rule .dim_set:N = \l_minibox_rule_dim , + pad .dim_set:N = \l_minibox_pad_dim , + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new:Npn \miniboxsetup #1 { \keys_set:nn {minibox} {#1} } +\miniboxsetup {l,m,rule=\fboxrule,pad=\fboxsep} +% \end{macrocode} +% +% \begin{macrocode} +\newcommand\minibox[2][] + { + \group_begin: + \keys_set:nn {minibox} {#1} + \bool_if:NTF \l_minibox_frame_bool + { + \setlength\fboxrule{\l_minibox_rule_dim} + \setlength\fboxsep{\l_minibox_pad_dim} + \fbox + } + { \use:n } + { + \begin{tabular} + [\l_minibox_tabular_valign_tl] + { @{} \l_minibox_tabular_preamble_tl @{} } + #2 + \end{tabular} + } + \group_end: + } +% \end{macrocode} |