New answers tagged

0

\strip@pt removes the unit pt and eTeX's \dimexpr can be used for the calculation: \documentclass{article} \usepackage{siunitx} \makeatletter % #1: macro, which gets the result of the conversion without unit % #2: length expression \newcommand*{\converttomm}[2]{% \edef#1{% \strip@pt\dimexpr(#2)*2540/7227\relax % 72.27 pt = 1 in = 25.4 mm }% } \...


0

Length conversion to decimal using LaTeX3: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn %\cs_new_eq:NN \calc \fp_eval:n \cs_new_eq:NN \convertlen \dim_to_decimal_in_unit:nn \ExplSyntaxOff \begin{document} \verb|\textwidth| in \verb|pt|s: \the\textwidth \makeatletter \verb|1mm| in \verb|pt|s: \setlength{\@tempdima}{1mm}\the\@tempdima \...


1

You can use my calculator package. The \LENGTHDIVIDE command divides two lengths and stores result as a number in a new command, as you need. Try this code: \documentclass[a4paper]{article} \usepackage{calculator} \begin{document} \LENGTHDIVIDE{\textwidth}{1mm}{\size} \size \end{document} In a standard a4 article \size returns 121.25427


4

A working method would be to use \pgfmathtruncatemacro instead of \multiply. This will calculate the result, and truncate the decimals. If you need decimals, you can use \pgfmathsetmacro. \documentclass[border=2mm]{standalone} \usepackage{tikz} \def\aa{3} \def\bb{1} \pgfmathtruncatemacro{\qq}{\aa*\bb} \usetikzlibrary{matrix} \begin{document} \begin{...


4

A \def\aa{3} does not allocate a count register. \multiply requires a count register (an 'integer variable'). Either use count registers or \the\numexpr \aa *\bb, the later works for integer numbers only, whereas \multiply can be used for numeric variables too. The example uses both way. \multiply\mynumberone by \mynumbertwo will multiply the contents ...


1

With some inspiration in this answer I came up with the following solution using a loop: \documentclass{article} \usepackage[table]{xcolor} \usepackage{booktabs,array,multicol} \newcommand*\TAB{&} \long\def\gloop #1\grepeat {\gdef \giterate {#1\expandafter \giterate \grepeat }\giterate } \let\grepeat\fi \newcounter{n} \newcounter{m} \newcounter{...


2

A better version: \documentclass{article} \usepackage{xcolor} \usepackage{booktabs} \usepackage[colorlinks=true,linkcolor={black}]{hyperref} \usepackage{colortbl} \newcommand{\TotalMonths}{24} \newcommand{\Year}[1]{ \multicolumn{12}{c|}{#1} } \newcommand{\Quarter}[1]{\multicolumn{3}{c|}{#1}} \newcommand{\FourQuarters}{\Quarter{I} & \Quarter{II} & ...


3

The following achieves what you're after: \documentclass{article} \begin{document} \newcounter{temp} \setcounter{temp}{-30} \newcommand{\haha}[1]{xyz-\hspace{\dimexpr#1+\value{temp} pt}-abc} \haha{90pt} xyz-\hspace{60pt}-abc% verification \end{document} I've used the LaTeX2e interface for counters, together with \value{<cntr>} to return a ...



Top 50 recent answers are included