Skip to content

Instantly share code, notes, and snippets.

@andreasWallner
Last active August 29, 2015 13:57
Show Gist options
  • Save andreasWallner/9724227 to your computer and use it in GitHub Desktop.
Save andreasWallner/9724227 to your computer and use it in GitHub Desktop.
LaTeX: print out lengths, converted into other units
% version using the layout package
\usepackage{layout}
\printinunitsof{cm}\prntlen{\textwidth} \prntlen{\textheight}
% Snippet by junanjo from www.latex-community.org (http://www.latex-community.org/forum/viewtopic.php?f=5&t=2712)
\usepackage{fp}
\newlength{\TOarg} \newlength{\TOunit}
{\catcode`p=12 \catcode`t=12 \gdef\TOnum#1pt{#1}}
\newcommand\TOop[2]{\setlength{\TOarg}{#2}%
\FPdiv\TOres{\expandafter\TOnum\the\TOarg}{\expandafter\TOnum\the\TOunit}%
\FPround\TOres\TOres{#1}}
\newcommand{\TOspace}{\ }
\newcommand\TOpt[2][2]{\setlength{\TOunit}{1pt}\TOop{#1}{#2}\TOres\TOspace pt}
\newcommand\TOin[2][2]{\setlength{\TOunit}{1in}\TOop{#1}{#2}\TOres\TOspace in}
\newcommand\TOcm[2][2]{\setlength{\TOunit}{1cm}\TOop{#1}{#2}\TOres\TOspace cm}
\newcommand\TOmm[2][2]{\setlength{\TOunit}{1mm}\TOop{#1}{#2}\TOres\TOspace mm}
\newcommand\TOem[2][2]{\setlength{\TOunit}{1em}\TOop{#1}{#2}\TOres\TOspace em}
\TOcm{\textwidth}
\TOcm{\tabcolsep}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment