\input pdfToolbox \input measurebox \setlayout{horizontal margin=2cm, vertical margin=2cm} \parindent=0pt \parskip=3pt plus 2pt minus 2pt \loadsyntax{TeX} \setsyntax{TeX} \everylisting={\lstlinenum=\z@} \def\mb{{\bf MeasureBox}} \def\macro#1{{\setfont{tt}\string#1}} \def\displaymacro#1{\quitvmode\kern-1cm\macro#1} \def\@setupverb{\setupverb\catcode`\ =10\relax} \def\inlinecode#1{ \bgroup% \@setupverb% \catcode`#1=2% \tt% } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \centerline{\mbscalebox{5}{\mb}} \bigskip \centerline{Version \measureboxversion} \centerline{\measureboxauthor\ ---\ \measureboxemail} \bigskip \bgroup \leftskip=3cm plus 1fil \rightskip=\leftskip \hrule \medskip \mb{} is a package designed for measuring material. Its only dependency is the \url{https://ctan.org/pkg/pdftoolbox?lang=en}{\pdftoolbox} toolkit.\par \medskip \hrule \egroup \bigskip It provides four main macros: \blist \item \macro\mbscalebox; \item \macro\measurebox; \item \macro\measureh; \item \macro\measurew. \elist \displaymacro\mbscalebox{} is the simplest. It takes two inputs: a scale factor and material to scale, and then scales the material by the given factor. For example \blisting \mbscalebox{5}{Hello!} \elisting Will produce \centerline{\mbscalebox{5}{Hello!}} \bigskip \displaymacro\measurebox{} is the main player. It takes two arguments: the first is the material to measure, and the second is a list of \macro\measureh{} and \macro\measurew{} commands to add measurements. \macro\measurebox{} will draw a box around the material with a stroke width governed by \macro\mbstrokewd{} (non-dimension), with a dash pattern of \macro\mbdashwd{} (dimension), and a color determined by the color {\tt mbcolor}. It will then scale this box by a factor of \macro\mbscale. After boxing the material, \macro\measurebox{} sets \macro\mbwd, \macro\mbht, and \macro\mbdp{} to the width, height, and depth of the box respectively. These can then be used by the measurement commands. \displaymacro\measureh{} measures vertical dimensions. It accepts a single input, which is a list of key-value pairs. These keys are: \blist \item {\tt b} (default: \inlinecode|-\the\mbdp|): the height at which to begin the measurement; \item {\tt e} (required): the height at which to end the measurement; \item {\tt x} (default: \inlinecode|.5\mbwd|): the x-position to place the line connecting the beginning and end measurement; \item {\tt stroke} (default: .01): the stroke weight of the measurement; \item {\tt label}: the label of the measurement; \item {\tt color} (default: {\tt black}): the color to draw the measurement; \item {\tt dash}: the dash length to stroke the measurement with, if provided; \item {\tt legend} (valueless): add to add this measurement to the legend; \item {\tt noprint} (valueless): add to not print the label on the measurement. \elist \displaymacro\measurew{} measures horizontal dimensions. It accepts a single input, which is a list of key-value pairs. These keys are the same as \macro\measureh, except {\tt x} is swapped with {\tt y}, and the meanings of {\tt b}, {\tt e}, {\tt x} are the dual of their meanings for \macro\measureh{} (i.e. {\tt b} is the {\it width} at which to begin the measurement). The font scale at which the labels are printed (before magnification) is determined by \macro\mblblscale. For example \blisting \def\mbscale{7} \def\mbstrokewd{.01} \def\mblblscale{1pt} \measurebox{\mbnodp{$\prod$}}{% \measureh{b=.5\mbht, e=10pt, stroke=.01, color=blue, dash=.1, label=(top stroke top), noprint, legend}% \measureh{b=.5\mbht, e=9.6pt, stroke=.01, color=blue, dash=.1, label=(top stroke bot), noprint, legend}% \measurew{b=1.59pt, e=2.56pt, stroke=.01, color=red, dash=.1, label=(left stroke), noprint, legend}% \measurew{b=\mbwd-2.574pt, e=\mbwd, stroke=.01, color=red, dash=.1, label=(right stroke left), noprint, legend, y=.5\mbht-1pt}% \measurew{e=\mbwd, b=\mbwd-1.604pt, stroke=.01, color=red, dash=.1, label=(right stroke right), noprint, legend, y=.5\mbht-1pt}% \measurew{e=\mbwd, stroke=.01, color=green, y=2pt, label=(width), legend}% } \elisting will produce \bigskip \def\mbscale{7} \def\mbstrokewd{.01} \def\mblblscale{1pt} \centerline{\measurebox{\mbnodp{$\prod$}}{% \measureh{b=.5\mbht, e=10pt, stroke=.01, color=blue, dash=.1, label=(top stroke top), noprint, legend}% \measureh{b=.5\mbht, e=9.6pt, stroke=.01, color=blue, dash=.1, label=(top stroke bot), noprint, legend}% \measurew{b=1.59pt, e=2.56pt, stroke=.01, color=red, dash=.1, label=(left stroke), noprint, legend}% \measurew{b=\mbwd-2.574pt, e=\mbwd, stroke=.01, color=red, dash=.1, label=(right stroke left), noprint, legend, y=.5\mbht-1pt}% \measurew{e=\mbwd, b=\mbwd-1.604pt, stroke=.01, color=red, dash=.1, label=(right stroke right), noprint, legend, y=.5\mbht-1pt}% \measurew{e=\mbwd, stroke=.01, color=green, y=2pt, label=(width), legend}% }} \bye