summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/rulerbox/rulerbox.sty
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/rulerbox/rulerbox.sty')
-rw-r--r--macros/latex/contrib/rulerbox/rulerbox.sty153
1 files changed, 153 insertions, 0 deletions
diff --git a/macros/latex/contrib/rulerbox/rulerbox.sty b/macros/latex/contrib/rulerbox/rulerbox.sty
new file mode 100644
index 0000000000..cd4537b91d
--- /dev/null
+++ b/macros/latex/contrib/rulerbox/rulerbox.sty
@@ -0,0 +1,153 @@
+%% rulerbox.sty
+%% Copyright 2019 Yuchang Yang < yang.yc.allium@gmail.com >
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Yuchang Yang.
+%
+% This work consists of the files rulerbox.sty, rulerbox.tex and
+% the generated manual file rulerbox.pdf.
+%%
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{rulerbox}[2019/04/18 v1.01 package rulerbox]
+\makeatletter
+\def\vb@xt@{\vbox to}
+\newdimen\rulerunit
+ \rulerunit=1mm
+\newdimen\rulerwidth
+ \rulerwidth=7pt
+\newdimen\rulersep
+ \rulersep=3pt
+\newdimen\rtickrule
+ \rtickrule=.4pt
+\newdimen\dim@margin
+\newdimen\dim@total@height
+\newdimen\dim@depth
+\def\ruler@vcells#1#2{%
+ \leaders\vb@xt@#1\rulerunit{%
+ \kern-.5\rtickrule
+ \hrule\@height\rtickrule\@width#2\rulerwidth
+ \vss}%
+ \vfill\kern-#1\rulerunit}
+\def\ruler@hcells#1#2{%
+ \leaders\hb@xt@#1\rulerunit{%
+ \kern-.5\rtickrule
+ \vrule\@width\rtickrule\@height#2\rulerwidth
+ \hss}%
+ \hfill\kern-#1\rulerunit}
+\newif\ifrulertop
+ \rulertoptrue
+\newif\ifrulerbottom
+ \rulerbottomtrue
+\newif\ifrulerleft
+ \rulerlefttrue
+\newif\ifrulerright
+ \rulerrighttrue
+\newif\ifruler@t
+\newif\ifruler@b
+\newif\ifruler@l
+\newif\ifruler@r
+\newbox\box@content
+\newbox\box@ruler@left
+\newbox\box@ruler@right
+\newbox\box@ruler@top
+\newbox\box@ruler@bottom
+\def\rulerbox{%
+ \let\ifruler@t\ifrulertop
+ \let\ifruler@b\ifrulerbottom
+ \let\ifruler@l\ifrulerleft
+ \let\ifruler@r\ifrulerright
+ \@ifnextchar[%]
+ {\ruler@box@option}{\ruler@box}}
+\def\ruler@box@option[#1]{%
+ \ruler@tfalse
+ \ruler@bfalse
+ \ruler@lfalse
+ \ruler@rfalse
+ \@tfor\@iterator:=#1\do{\csname ruler@\@iterator true\endcsname}%
+ \ruler@box}
+\long\def\ruler@box#1{%
+ \leavevmode
+ \setbox\box@content=\hbox{#1}%
+ \dim@margin=\rulerwidth
+ \advance\dim@margin\rulersep
+ \dim@total@height=\ht\box@content
+ \advance\dim@total@height\dp\box@content
+ \dim@depth=\dp\box@content
+ \ifruler@b
+ \advance\dim@depth\dim@margin
+ \fi
+ \rulers@prepare
+ \ruler@box@
+}
+\def\rulers@prepare{%
+ \ifruler@l\setbox\box@ruler@left=\hbox{\lower\dp\box@content\hbox{%
+ \ooalign{%
+ \vb@xt@\dim@total@height{\ruler@vcells{10}{1. }}\cr
+ \hidewidth\vb@xt@\dim@total@height{\ruler@vcells{ 5}{ .75}}\cr
+ \hidewidth\vb@xt@\dim@total@height{\ruler@vcells{ 1}{ .5 }}\cr
+ }%
+ }}\fi%
+ \ifruler@r\setbox\box@ruler@right=\hbox{\lower\dp\box@content\hbox{%
+ \ooalign{%
+ \vb@xt@\dim@total@height{\ruler@vcells{10}{1. }}\cr
+ \vb@xt@\dim@total@height{\ruler@vcells{ 5}{ .75}}\hidewidth\cr
+ \vb@xt@\dim@total@height{\ruler@vcells{ 1}{ .5 }}\hidewidth\cr
+ }%
+ }}\fi%
+ \ifruler@t\setbox\box@ruler@top=\hbox{%
+ \ooalign{%
+ \hb@xt@\wd\box@content{\ruler@hcells{10}{1 }}\cr
+ \hb@xt@\wd\box@content{\ruler@hcells{ 5}{ .75}}\cr
+ \hb@xt@\wd\box@content{\ruler@hcells{ 1}{ .5 }}\cr
+ }%
+ }\fi%
+ \ifruler@b\setbox\box@ruler@bottom=\hbox{%
+ \ooalign{%
+ \vb@xt@\rulerwidth{\hb@xt@\wd\box@content{\ruler@hcells{10}{1 }}\vss}\cr
+ \vb@xt@\rulerwidth{\hb@xt@\wd\box@content{\ruler@hcells{ 5}{ .75}}\vss}\cr
+ \vb@xt@\rulerwidth{\hb@xt@\wd\box@content{\ruler@hcells{ 1}{ .5 }}\vss}\cr
+ }%
+ }\fi}
+\def\ruler@box@{%
+ \lower\dim@depth\hbox{%
+ \ifruler@l\kern\dim@margin\fi
+ \vbox{%
+ \ifruler@t
+ \box\box@ruler@top
+ \nointerlineskip
+ \kern\rulersep
+ \fi
+ \hbox{%
+ \ifruler@l
+ \kern-\dim@margin
+ \box\box@ruler@left
+ \kern\rulersep
+ \fi
+ \box\box@content
+ \ifruler@r
+ \kern\rulersep
+ \box\box@ruler@right
+ \kern-\dim@margin
+ \fi
+ }%
+ \ifruler@b
+ \nointerlineskip
+ \kern\rulersep
+ \box\box@ruler@bottom
+ \fi
+ \kern\z@
+ }%
+ \ifruler@r\kern\dim@margin\fi
+ }}
+\makeatother
+%%
+%% End of file `rulerbox.sty'