summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/xprintlen
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/xprintlen
Initial commit
Diffstat (limited to 'macros/latex/contrib/xprintlen')
-rw-r--r--macros/latex/contrib/xprintlen/LICENSE5
-rw-r--r--macros/latex/contrib/xprintlen/README53
-rw-r--r--macros/latex/contrib/xprintlen/ex01.pngbin0 -> 32132 bytes
-rw-r--r--macros/latex/contrib/xprintlen/xprintlen.pdfbin0 -> 109654 bytes
-rw-r--r--macros/latex/contrib/xprintlen/xprintlen.sty34
-rw-r--r--macros/latex/contrib/xprintlen/xprintlen.tex77
6 files changed, 169 insertions, 0 deletions
diff --git a/macros/latex/contrib/xprintlen/LICENSE b/macros/latex/contrib/xprintlen/LICENSE
new file mode 100644
index 0000000000..136054bcdb
--- /dev/null
+++ b/macros/latex/contrib/xprintlen/LICENSE
@@ -0,0 +1,5 @@
+Released under the [LaTeX Project Public
+License](http://www.latex-project.org/lppl.txt), v1.3c or later.
+
+The package has status 'maintained': the current maintainer is
+[Liam Huang](liamhuang0205+xprintlen@gmail.com).
diff --git a/macros/latex/contrib/xprintlen/README b/macros/latex/contrib/xprintlen/README
new file mode 100644
index 0000000000..d40a8cdaa2
--- /dev/null
+++ b/macros/latex/contrib/xprintlen/README
@@ -0,0 +1,53 @@
+ =========================
+ The xprintlen Package
+ =========================
+
+
+Introduction
+------------
+
+This package defines a command, \printlen, to print lengths
+in a variety of units.
+
+This work is released under the LaTeX Project Public License,
+v1.3c or later. See the License file.
+
+Installation
+------------
+
+This package consists of the files xprintlen.sty,
+ xprintlen.tex,
+ xprintlen.pdf,
+ ex01.png,
+ README,
+ LICENSE.
+
+* Copy the files into proper directories searched by TeX.
+ TDS tree:
+
+ TEXMF/doc/latex/xprintlen/xprintlen.tex
+ TEXMF/doc/latex/xprintlen/xprintlen.pdf
+ TEXMF/doc/latex/xprintlen/ex01.png
+ TEXMF/doc/latex/xprintlen/README
+ TEXMF/doc/latex/xprintlen/LICENSE
+ TEXMF/tex/latex/xprintlen/xprintlen.sty
+
+* Run texhash to refresh file name data base.
+
+Basic Usage
+-----------
+
+You can read the PDF document for detailed explanations.
+
+Author
+------
+
+Liam Huang
+
+Email: liamhuang0205+xprintlen@gmail.com
+
+If you are interested in the process of development you may observe
+
+ https://github.com/LiamHuang0205/xprintlen
+
+--- end of README ---
diff --git a/macros/latex/contrib/xprintlen/ex01.png b/macros/latex/contrib/xprintlen/ex01.png
new file mode 100644
index 0000000000..8b5ab48abf
--- /dev/null
+++ b/macros/latex/contrib/xprintlen/ex01.png
Binary files differ
diff --git a/macros/latex/contrib/xprintlen/xprintlen.pdf b/macros/latex/contrib/xprintlen/xprintlen.pdf
new file mode 100644
index 0000000000..b657f7c50c
--- /dev/null
+++ b/macros/latex/contrib/xprintlen/xprintlen.pdf
Binary files differ
diff --git a/macros/latex/contrib/xprintlen/xprintlen.sty b/macros/latex/contrib/xprintlen/xprintlen.sty
new file mode 100644
index 0000000000..ec7cccf2df
--- /dev/null
+++ b/macros/latex/contrib/xprintlen/xprintlen.sty
@@ -0,0 +1,34 @@
+%%
+%% This is file `xprintlen.sty',
+%% part of the package xprintlen.
+%%
+%% Copyright (C) 2014 by Liam Huang <liamhuang0205+xprintlen@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.
+%%
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{xprintlen}[2014/12/25 v1.0 print lengths with units]
+\RequirePackage{fp}
+\newlength{\CMarg}
+\newlength{\CMunit}
+\newcommand{\CMspace}{\,}
+\newcommand{\defaultunit}{mm}
+\newcommand{\defaultsignificant}{2}
+\newcommand*{\printlen}[1][\defaultsignificant]{%
+ \providecommand{\printlenFirstParameter}{}%
+ \renewcommand{\printlenFirstParameter}{#1}%
+ \printlenCalculate%
+}
+\newcommand*{\printlenCalculate}[2][\defaultunit]{%
+ \setlength{\CMunit}{1#1}%
+ \setlength{\CMarg}{#2}%
+ \FPdiv\CMres{\strip@pt\CMarg}{\strip@pt\CMunit}%
+ \FPround\CMres\CMres{\printlenFirstParameter}%
+ \CMres\CMspace\texttt{#1}%
+}
diff --git a/macros/latex/contrib/xprintlen/xprintlen.tex b/macros/latex/contrib/xprintlen/xprintlen.tex
new file mode 100644
index 0000000000..827fddfe5f
--- /dev/null
+++ b/macros/latex/contrib/xprintlen/xprintlen.tex
@@ -0,0 +1,77 @@
+%%
+%% This is file `xprintlen.tex',
+%% part of the package xprintlen.
+%%
+%% Copyright (C) 2014 by Liam Huang <liamhuang0205+xprintlen@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.
+%%
+%!TEX option = -shell-escape
+%!TEX builder = latexmk
+\documentclass{article}
+\title{\bfseries The \textsf{xprintlen} package\thanks{This manual corresponds to \textsf{xprintlen.sty} v1.0, dated 2014/12/25}{\hspace{6pt}}\thanks{This work is released under the LaTeX Project Public
+License (\url{http://www.latex-project.org/lppl.txt}), v1.3c or later.}}
+\author{Liam Huang\thanks{\url{http://liam0205.me/}, \href{mailto:liamhuang0205+xprintlen@gmail.com}{liamhuang0205+xprintlen@gmail.com}}}
+\date{2014/12/25}
+\usepackage{mathpazo}
+\usepackage{minted}
+\usepackage{graphicx}
+\usepackage{hyperref}
+\hypersetup{hidelinks}
+\usepackage{geometry}
+\geometry{letterpaper, top = 1in, bottom = 1in}
+
+\begin{document}
+\maketitle
+
+\section{Requirements}
+
+\textsf{xprintlen} requires the package \textsf{fp} to be available and reasonably up to date on your system.
+
+\section{Installation}
+
+Put the \textsf{.sty} file into the folder \texttt{TEXMF/tex/latex/xprintlen}, and put other files into another folder \texttt{TEXMF/doc/latex/xprintlen}. Run \texttt{texhash} to refresh the file name data base.
+
+\section{Usage}
+
+This package defines a command, \verb|\printlen|, to print lengths in a variety of units. It supports all the units that \TeX{} supports, and its calculation depends on the package \textsf{fp}.
+
+\verb|\printlen| recieves three parameters, while the first two parameters are the optionals. The first (optional) parameter sets the length of significant digits, whose default value is $ 2 $, stored in the marco \verb|\defaultsignificant|. The second (optional) parameter sets the unit to be print, and the default value of it is \texttt{mm}, stored in the marco \verb|\defaultunit|. The third parameter of the command, also the only mandatory parameter, is the length that will be calculated.
+
+You can redefine the two marcos to revise the default length of significant digits and/or the default unit.
+
+\section{Example}
+
+\noindent\begin{minipage}[b]{0.55\linewidth}
+The following lines will produce:
+
+\begin{minted}{latex}
+\documentclass{article}
+\usepackage{xprintlen}
+\newlength{\testlen}
+\setlength{\testlen}{3.1415926cm}
+\begin{document}
+\obeylines
+\printlen{\testlen}
+\printlen[5]{\testlen}
+\printlen[5][pt]{\testlen}
+\end{document}
+\end{minted}
+\end{minipage}%
+\begin{minipage}[b]{0.45\linewidth}
+\includegraphics[scale = 0.6]{ex01}
+\end{minipage}
+
+\section{Change log}
+
+\subsection*{Version 1.0, 2014/12/25}
+\begin{itemize}
+ \item The first public release.
+\end{itemize}
+\end{document}