| 1 |
%% |
| 2 |
%% This is file `settobox-example.tex', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% settobox.dtx (with options: `example') |
| 8 |
%% |
| 9 |
%% This is a generated file. |
| 10 |
%% |
| 11 |
%% Project: settobox |
| 12 |
%% Version: 2016/05/16 v1.5 |
| 13 |
%% |
| 14 |
%% Copyright (C) |
| 15 |
%% 2000, 2006-2008 Heiko Oberdiek |
| 16 |
%% 2016-2019 Oberdiek Package Support Group |
| 17 |
%% |
| 18 |
%% This work may be distributed and/or modified under the |
| 19 |
%% conditions of the LaTeX Project Public License, either |
| 20 |
%% version 1.3c of this license or (at your option) any later |
| 21 |
%% version. This version of this license is in |
| 22 |
%% https://www.latex-project.org/lppl/lppl-1-3c.txt |
| 23 |
%% and the latest version of this license is in |
| 24 |
%% https://www.latex-project.org/lppl.txt |
| 25 |
%% and version 1.3 or later is part of all distributions of |
| 26 |
%% LaTeX version 2005/12/01 or later. |
| 27 |
%% |
| 28 |
%% This work has the LPPL maintenance status "maintained". |
| 29 |
%% |
| 30 |
%% The Current Maintainers of this work are |
| 31 |
%% Heiko Oberdiek and the Oberdiek Package Support Group |
| 32 |
%% https://github.com/ho-tex/oberdiek/issues |
| 33 |
%% |
| 34 |
%% |
| 35 |
%% This work consists of the main source file settobox.dtx |
| 36 |
%% and the derived files |
| 37 |
%% settobox.sty, settobox.pdf, settobox.ins, settobox.drv, |
| 38 |
%% settobox-example.tex. |
| 39 |
%% |
| 40 |
\documentclass{article} |
| 41 |
|
| 42 |
\usepackage{settobox} |
| 43 |
\usepackage{calc} |
| 44 |
|
| 45 |
\newsavebox{\mybox} |
| 46 |
|
| 47 |
\setlength{\fboxsep}{0pt} |
| 48 |
\setlength{\parindent}{20pt} |
| 49 |
\setlength{\parskip}{10pt} |
| 50 |
\pagestyle{empty} |
| 51 |
|
| 52 |
% \test{#1} |
| 53 |
% The macro is called with commands in #1 that manipulates |
| 54 |
% the box \mybox. These commands along with the result of |
| 55 |
% the manipulation is shown. Thus the essence of the |
| 56 |
% macro is: |
| 57 |
% |
| 58 |
% a) \sbox{\mybox}{The cracy fox.} |
| 59 |
% b) #1 % manipulates \mybox |
| 60 |
% c) Print #1 commands. |
| 61 |
% d) Print box with frame |
| 62 |
% |
| 63 |
% The implementation looks more weird: |
| 64 |
\makeatletter |
| 65 |
\newcommand*{\test}[1]{% |
| 66 |
\par |
| 67 |
\begingroup |
| 68 |
\raggedright |
| 69 |
\edef\x{\detokenize{#1}}% |
| 70 |
\let\do\@makeother |
| 71 |
\dospecials |
| 72 |
\catcode`\~\active |
| 73 |
\catcode`\ =10\relax |
| 74 |
\def~{\\}% |
| 75 |
\noindent |
| 76 |
\texttt{\scantokens\expandafter{\x}}% |
| 77 |
\par |
| 78 |
\endgroup |
| 79 |
\begingroup |
| 80 |
\let~\relax |
| 81 |
\sbox{\mybox}{The cracy fox.}% |
| 82 |
#1% |
| 83 |
A---\fbox{\usebox\mybox}---B% |
| 84 |
\endgroup |
| 85 |
\par |
| 86 |
} |
| 87 |
\makeatother |
| 88 |
|
| 89 |
\begin{document} |
| 90 |
|
| 91 |
\test{\setboxwidth{\mybox}{1.25\width}} |
| 92 |
\test{\setboxheight{\mybox}{0pt}} |
| 93 |
\test{\setboxheight{\mybox}{2\height}} |
| 94 |
\test{\setboxdepth{\mybox}{\height}} |
| 95 |
\test{\setboxmoveleft{\mybox}{5pt}} |
| 96 |
\test{% |
| 97 |
\setboxmoveleft{\mybox}{5pt}~% |
| 98 |
\setboxwidth{\mybox}{\width + 5pt}% |
| 99 |
} |
| 100 |
\test{\setboxmoveright{\mybox}{0.5\width}} |
| 101 |
\test{\setboxlower{\mybox}{\height}} |
| 102 |
\test{\setboxraise{\mybox}{\depth}} |
| 103 |
\test{% |
| 104 |
\setboxmoveright{\mybox}{5pt}~% |
| 105 |
\setboxwidth{\mybox}{\width + 5pt}~% |
| 106 |
\setboxheight{\mybox}{\height + 5pt}~% |
| 107 |
\setboxdepth{\mybox}{\depth + 5pt}% |
| 108 |
} |
| 109 |
|
| 110 |
\end{document} |
| 111 |
\endinput |
| 112 |
%% |
| 113 |
%% End of file `settobox-example.tex'. |