Debian Codegraph @

texmf-dist/doc/latex/rulerbox/rulerbox.tex

raw
1 %% rulerbox.tex
2 %% Copyright 2019 Yuchang Yang < [email protected] >
3 %
4 % This work may be distributed and/or modified under the
5 % conditions of the LaTeX Project Public License, either version 1.3
6 % of this license or (at your option) any later version.
7 % The latest version of this license is in
8 % http://www.latex-project.org/lppl.txt
9 % and version 1.3 or later is part of all distributions of LaTeX
10 % version 2005/12/01 or later.
11 %
12 % This work has the LPPL maintenance status `maintained'.
13 %
14 % The Current Maintainer of this work is Yuchang Yang.
15 %
16 % This work consists of the files rulerbox.sty, rulerbox.tex and
17 % the generated manual file rulerbox.pdf.
18
19 \documentclass[a4paper,11pt]{article}
20
21 \usepackage{rulerbox}
22 \usepackage{fontspec}
23 \usepackage{color}
24 \definecolor{darkmiku}{RGB}{19, 149, 139}
25
26 \newdimen\sidelength
27 \sidelength=2cm
28 \newdimen\boxkern
29 \boxkern=2mm
30 \newdimen\mydimen
31 \mydimen=\sidelength
32 \advance\mydimen-.8pt
33
34 \def\lan{\ensuremath{\langle}}
35 \def\ran{\ensuremath{\rangle}}
36 \def\param#1{\textrm{\lan\textit{#1}\ran}}
37 \def\texttt#1{{\ttfamily\color{darkmiku}#1}}
38 \def\cbox#1{\rulerbox[#1]{\ooalign{%
39 \rule{\sidelength}{\sidelength}\cr
40 \hidewidth\raisebox{.4pt}{\color{white}\rule{\mydimen}{\mydimen}}\hidewidth\cr
41 \hidewidth\vbox to \sidelength{\vss\hbox to \sidelength{\hss\texttt{[#1]}\hss}\vss}\hidewidth\cr
42 }}}
43
44 \title{\hspace*{1cm}The \textsf{rulerbox} package\footnotemark[1]\hspace*{1cm}}
45 \author{Yuchang \textsc{Yang}{\fontspec{SimSun}(杨宇昌)\kern-5pt\footnotemark[2]}}
46 \date{April 18\textsuperscript{th}, 2019\qquad ver.~1.01}
47
48 \begin{document}
49
50 \parskip=1ex
51
52 \begin{centering}
53 \vspace*{-2em}
54 \rulersep=5pt
55 \rulerwidth=5mm
56 \let\newpage\relax
57 \rulerbox{\parbox{.7\linewidth}{\vspace*{-2em}\maketitle\vspace*{-1.5em}}}\par
58 \vskip1.5em
59 \def\thefootnote{\fnsymbol{footnote}}
60 \footnotetext[1]{Github repository: \texttt{https://github.com/Mikumikunisiteageru/rulerbox}}
61 \footnotetext[2]{Email address: \texttt{[email protected]}}
62 \end{centering}
63
64 \section{Introduction}
65 \textsf{rulerbox} is an independent \LaTeX\ package providing macro \texttt{\string\rulerbox}, which draws rulers along edges of an object, in the following style:\par
66 \vskip-1mm
67 \centerline{{\rulersep=-.4pt\rulerwidth=5mm\rulerbox[b]{\rule{10cm}{0pt}}}}
68 \smallskip
69 This might be useful when showing the absolute size of something in electronic documents, or designating the relative scale in printed materials.
70
71 \section{Usage}
72
73 % \subsection{Basic syntax}
74 \texttt{\string\rulerbox\{\param{content}\}} somewhat resembles the macro \texttt{\string\fbox\{\param{content}\}} defined by \LaTeX. The one mandatory parameter that they receive is the content to be wrapped inside a box. Then \texttt{\string\rulerbox} decorates the box edges with rulers, whereas \texttt{\string\fbox} frames the box by solid lines. Neither of them affects the vertical alignment.\par
75 \medskip
76 \centerline{\fontsize{50}{50}\selectfont ra\rulerbox{g}ge\fbox{d}ri\fbox{g}\rulerbox{h}t}
77
78 \subsection{Edge selection}
79 \texttt{\string\rulerbox[\param{edges}]\{\param{content}\}} also accepts an optional parameter, telling \LaTeX{} which edges to be decorated with rulers. \texttt{\param{edges}} is any subset of \texttt{t}, \texttt{b}, \texttt{l}, and \texttt{r}, controlling the top, bottom, left, and right edges respectively. So \texttt{\string\rulerbox[tblr]\{\param{content}\}} behaves identically the same as \texttt{\string\rulerbox\{\param{content}\}} (unless default switches are turned off, see below), while \texttt{\string\rulerbox[]\{\param{content}\}} regresses to \texttt{\string\hbox\{\param{content}\}}.\par
80 \medskip
81 \centerline{\vbox{%
82 \hbox{\cbox{tl}\kern\boxkern\cbox{t}\kern\boxkern\cbox{tr}}%
83 \nointerlineskip\kern\boxkern
84 \hbox{\cbox{l}\kern\boxkern\cbox{}\kern\boxkern\cbox{r}}%
85 \nointerlineskip\kern\boxkern
86 \hbox{\cbox{bl}\kern\boxkern\cbox{b}\kern\boxkern\cbox{br}}%
87 }}
88 \smallskip
89 Default status of each edge can be set separately and globally by switching \texttt{\textbackslash ifrulertop}, \texttt{\textbackslash ifrulerbottom}, \texttt{\textbackslash ifrulerleft}, and \texttt{\textbackslash ifrulerright}. For example, \texttt{\string\rulerleftfalse} suppresses all left rulers (except required explicitly by \texttt{\param{edges}}), until a \texttt{\string\rulerlefttrue} is seen.\par
90
91 \subsection{Dimensions}
92 Four dimensions are involved in the \textsf{rulerbox} package. They can be redefined locally by \texttt{\param{dimen name}=\param{dimen express}\string\relax} in \TeX\ style, or globally by \texttt{\string\setlength\{\param{dimen name}\}\{\param{dimen express}\}} in \LaTeX\ style.
93 \begin{itemize}
94 \item \texttt{\string\rulerunit}: The \textsl{least count} of rulers, \textit{i.e.}\ distance between adjacent ticks in rulers. Default is \texttt{1mm}, one millimetre, which produces rulers of metric length system. \texttt{\string\rulerunit} may be redefined to adapt to other \textsl{decimal} length systems, or draw rulers of relative scales.\par
95 For example, if one wants to switch to Chinese length units, he may define \texttt{\string\rulerunit=1cm\string\divide\string\rulerunit3\string\relax}, which makes the least count 10/3 mm, namely one \textit{fen}{\fontspec{SimSun}(分)}\kern-4pt, or one tenth \textit{cun}{\fontspec{SimSun}(寸)}\kern-4pt.\par
96 \vskip-6mm
97 \hbox{}\hfill{\rulerunit=1cm\divide\rulerunit3\relax\rulersep=-6pt\rulerwidth=5mm\rulerbox[b]{\rule{10cm}{0pt}}}\hfill\hbox{}\par
98 \smallskip
99 \item \texttt{\string\rulersep}: Distance between box edges and rulers. Default is \texttt{3pt}.
100 \item \texttt{\string\rulerwidth}: Length of longest ticks in rulers. Default is \texttt{7pt}.
101 \item \texttt{\string\rtickrule}: Width of tick lines in rulers. Default is \texttt{0.4pt}.
102 \end{itemize}
103
104 \end{document}