summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/printlen
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/printlen
Initial commit
Diffstat (limited to 'macros/latex/contrib/printlen')
-rw-r--r--macros/latex/contrib/printlen/printlen-doc.pdfbin0 -> 243193 bytes
-rw-r--r--macros/latex/contrib/printlen/printlen-doc.tex102
-rw-r--r--macros/latex/contrib/printlen/printlen.sty137
3 files changed, 239 insertions, 0 deletions
diff --git a/macros/latex/contrib/printlen/printlen-doc.pdf b/macros/latex/contrib/printlen/printlen-doc.pdf
new file mode 100644
index 0000000000..ec287bd077
--- /dev/null
+++ b/macros/latex/contrib/printlen/printlen-doc.pdf
Binary files differ
diff --git a/macros/latex/contrib/printlen/printlen-doc.tex b/macros/latex/contrib/printlen/printlen-doc.tex
new file mode 100644
index 0000000000..2f3f912086
--- /dev/null
+++ b/macros/latex/contrib/printlen/printlen-doc.tex
@@ -0,0 +1,102 @@
+\documentclass[pagesize=auto, fontsize=12pt, DIV=10]{scrartcl}
+
+\usepackage{fixltx2e}
+\usepackage{etex}
+\usepackage{lmodern}
+\usepackage[T1]{fontenc}
+\usepackage{textcomp}
+\usepackage[svgnames]{xcolor}
+\usepackage{listings}
+\usepackage{microtype}
+\usepackage{hyperref}
+
+\newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}}
+\newcommand*{\pkg}[1]{\textsf{#1}}
+\newcommand*{\cs}[1]{\texttt{\textbackslash#1}}
+\makeatletter
+\newcommand*{\cmd}[1]{\cs{\expandafter\@gobble\string#1}}
+\makeatother
+\newcommand*{\meta}[1]{\textlangle\textsl{#1}\textrangle}
+\newcommand*{\marg}[1]{\texttt{\{}\meta{#1}\texttt{\}}}
+
+\addtokomafont{title}{\rmfamily}
+
+\lstset{%
+ language=[LaTeX]TeX,%
+ columns=flexible,%
+ upquote=true,%
+ numbers=left,%
+ basicstyle=\ttfamily,%
+ keywordstyle=\color{Navy},%
+ commentstyle=\color{DimGray},%
+ stringstyle=\color{SeaGreen},%
+ numberstyle=\scriptsize\color{SlateGray}%
+}
+
+\title{The \pkg{printlen} package\thanks{This manual corresponds to \pkg{printlen.sty}~v1.1a, dated~2009/09/03.}}
+\subtitle{Print lengths in a variety of units}
+\author{Peter Wilson, Herries Press\and Harald Harders\thanks{\mail{h.harders@tu-bs.de}}\and Maintainer: Will Robertson\thanks{\mail{will.robertson.@latex-project.org}}}
+\date{2009/09/03}
+
+
+\begin{document}
+
+\maketitle
+
+
+\section{Usage}
+
+\cmd{\printlength}\marg{length} prints the value of a \LaTeX\ length in the
+units specified by \cmd{\uselengthunit}\marg{unit}, where \meta{unit} may be any \TeX\ %
+length unit except for scaled point. That is, \meta{unit} may be any of:
+\texttt{pt}, \texttt{pc}, \texttt{in}, \texttt{mm}, \texttt{cm}, \texttt{bp}, \texttt{dd} or \texttt{cc}. When \texttt{pt} is set the printed length
+value will include any stretch or shrink values, otherwise these
+are not printed. The \meta{unit} argument may also be \texttt{PT}, in which case
+length values will be printed in pt units but without any stretch
+or shrink values. An unknown value for \meta{unit} is treated as though it
+had been specified as \texttt{pt}.
+
+The unit is separated from the number using the command
+\cmd{\unitspace} which is set to \cmd{\,} by default. In math mode the units are
+printed upright.
+
+\cmd{\rndprintlength}\meta{length} prints the rounded value of a \LaTeX\ length.
+Use \texttt{PT} instead of \texttt{pt} for rounded points if there are stretch or
+shrink values.
+
+The initial setting is \verb+\uselengthunit{pt}+
+
+
+\minisec{Example:}
+
+\begin{lstlisting}
+The \verb|\textwidth| is \printlength{\textwidth} which is also
+\uselengthunit{in}\printlength{\textwidth} and
+\uselengthunit{mm}\printlength{\textwidth}.
+\end{lstlisting}
+
+
+\section{Change history}
+
+\minisec{Version 1.1a (2009/09/03)}
+
+\begin{itemize}
+\item New maintainer (Will Robertson)
+\end{itemize}
+
+
+\minisec{Version 1.1 (2001/12/09)}
+
+\begin{itemize}
+\item Print rounded values
+\item Space between value and units
+\end{itemize}
+
+
+\minisec{Version 1.0 (2001/11/03)}
+
+\begin{itemize}
+\item First public release
+\end{itemize}
+
+\end{document}
diff --git a/macros/latex/contrib/printlen/printlen.sty b/macros/latex/contrib/printlen/printlen.sty
new file mode 100644
index 0000000000..7156670a20
--- /dev/null
+++ b/macros/latex/contrib/printlen/printlen.sty
@@ -0,0 +1,137 @@
+% printlen.sty Print lengths in a variety of units
+%
+% Author: Peter Wilson, Herries Press
+% Maintainer: Will Robertson (will dot robertson at latex-project dot org)
+% Copyright 2001 Peter R. Wilson
+% Released under the LaTeX Project Public License
+%
+% Extensions courtesy of Harald Harders (h.harders@tu-bs.de)
+%
+% Usage instructions are at the end of this file.
+%
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{printlen}[2009/09/03 v1.1a print lengths with units]
+%
+% \uselengthunit{<unit>} sets \l@nunits to the value of <unit>
+% and \l@nunitperpt to the number of <unit> in 1pt.
+\newcommand{\uselengthunit}[1]{%
+ \def\l@nunitperpt{1.0}\def\l@nunits{pt}%
+ \def\l@nta{#1}\def\l@ntb{pt}%
+ \ifx \l@nta\l@ntb
+ \def\l@nunitperpt{1.0}\def\l@nunits{pt}%
+ \else
+ \def\l@ntb{pc}%
+ \ifx \l@nta\l@ntb
+ \def\l@nunitperpt{0.083333}\def\l@nunits{pc}%
+ \else
+ \def\l@ntb{in}%
+ \ifx \l@nta\l@ntb
+ \def\l@nunitperpt{0.013837}\def\l@nunits{in}%
+ \else
+ \def\l@ntb{mm}%
+ \ifx \l@nta\l@ntb
+ \def\l@nunitperpt{0.351459}\def\l@nunits{mm}%
+ \else
+ \def\l@ntb{cm}%
+ \ifx \l@nta\l@ntb
+ \def\l@nunitperpt{0.0351459}\def\l@nunits{cm}%
+ \else
+ \def\l@ntb{bp}%
+ \ifx \l@nta\l@ntb
+ \def\l@nunitperpt{0.996264}\def\l@nunits{bp}%
+ \else
+ \def\l@ntb{dd}%
+ \ifx \l@nta\l@ntb
+ \def\l@nunitperpt{0.9345718}\def\l@nunits{dd}%
+ \else
+ \def\l@ntb{cc}%
+ \ifx \l@nta\l@ntb
+ \def\l@nunitperpt{0.0778809}\def\l@nunits{cc}%
+ \else
+ \def\l@ntb{PT}%
+ \ifx \l@nta\l@ntb
+ \def\l@nunitperpt{1.0}\def\l@nunits{PT}%
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+}
+\uselengthunit{pt}
+
+% \printlength{<length>} prints the value of <length> in the units set
+% by \uselengthunit.
+\newcommand{\printlength}[1]{%
+ \def\l@nta{pt}\ifx\l@nta\l@nunits\the#1\else
+ \def\l@nta{PT}%
+ \@tempdimc=\l@nunitperpt #1\relax\strip@pt\@tempdimc
+ \unitspace\relax\ifmmode
+ \mathrm{\ifx\l@nta\l@nunits pt\else\l@nunits\fi}%
+ \else
+ \ifx\l@nta\l@nunits pt\else\l@nunits\fi
+ \fi\fi}
+
+% \rndprintlength{<length>} prints the rounded value of <length> in
+% the units set by \uselengthunit. Contributed by Harald Harders.
+\def\@round#1.#2\@empty{#1}%
+\newcommand{\rndprintlength}[1]{%
+ \def\l@nta{pt}\ifx\l@nta\l@nunits\the#1\else
+ \def\l@nta{PT}%
+ \setlength{\@tempdimc}{\l@nunitperpt #1}%
+ \addtolength{\@tempdimc}{0.5pt}%
+ \edef\@@round{\strip@pt\@tempdimc}%
+ \expandafter\@round\@@round.\@empty
+ \unitspace\relax\ifmmode
+ \mathrm{\ifx\l@nta\l@nunits pt\else\l@nunits\fi}%
+ \else
+ \ifx\l@nta\l@nunits pt\else\l@nunits\fi
+ \fi\fi}
+
+% Small space. Contributed by Harald Harders.
+\newcommand{\unitspace}{\,}
+
+\endinput
+
+% USAGE:
+%
+% \printlength{<length>} prints the value of a LaTeX length in the
+% units specified by \uselengthunit{<unit>}, where <unit> may be any TeX
+% length unit except for scaled point. That is, <unit> may be any of:
+% pt, pc, in, mm, cm, bp, dd or cc. When pt is set the printed length
+% value will include any stretch or shrink values, otherwise these
+% are not printed. The <unit> argument may also be PT, in which case
+% length values will be printed in pt units but without any stretch
+% or shrink values. An unknown value for <unit> is treated as though it
+% had been specified as pt.
+% The unit is separated from the number using the command
+% \unitspace which is set to \, by default. In math mode the units are
+% printed upright.
+% \rndprintlength{<length>} prints the rounded value of a LaTeX length.
+% Use PT instead of pt for rounded points if there are stretch or
+% shrink values.
+%
+% The initial setting is \uselengthunit{pt}
+%
+% Example:
+%
+% The \verb|\textwidth| is \printlength{\textwidth} which is also
+% \uselengthunit{in}\printlength{\textwidth} and
+% \uselengthunit{mm}\printlength{\textwidth}.
+%
+%
+% CHANGE HISTORY
+%
+% Version 1.1a (2009/09/03)
+% - New maintainer (Will Robertson)
+%
+% Version 1.1 (2001/12/09)
+% - Print rounded values
+% - Space between value and units
+%
+% Version 1.0 (2001/11/03)
+% - First public release
+%