# Tag Info

4

e-TeX's \dimexpr can be used: \newcommand{\sxfigure}[4]{% \includegraphics[width=#3\dimexpr#1cm\relax, height=#3\dimexpr#2cm\relax]{#4}% }

9

It's “simple” with xparse and siunitx. I define \setvariable with three arguments: the variable name, the value and the unit \printvariable with one argument and a *-form; the *-form prints just the value with \num, whereas the non-starred form prints value and unit with \SI \getvalue that retrieves the value of the variable given as argument to be used in ...

5

Here's a sagetex approach to implementing a variation on Mico's code. Since it uses Python, it can be easier to see what's going on. But you need Sage installed on your computer or use SagemathCloud if you don't want Sage installed on your computer. \documentclass{article} \usepackage{sagetex} \begin{document} \begin{sagesilent} SRS = 14839.9 Italy = ...

5

Instead of pure LaTeX, I suggest mix LaTeX with R code in a "R-noweb" file (plain text file but with the .Rnw extension): \documentclass{article} \begin{document} <<results='hide'>>= Italy <- 800000 # km of road by Wikipedia SRS <- 14839.9 # km the paths of the project SRSpercent <- SRS / Italy * 100 @ The value of SRSpercent is ...

14

Here's a solution that uses LuaLaTeX. No additional floating-point routines need be loaded. The output precision is controlled by the first argument of the string.format function; in the example below, the code is set to show 3 digits after the decimal marker. % !TEX TS-program = lualatex %% needs LuaLaTeX format \documentclass{article} ...

1

LaTeX expects that package options are simple strings or something, that expands to simple strings. A length register cannot be expanded and will break, for example, when LaTeX tries to find out, if the option is defined. A length register can be expanded by prefixing it with \the: \usepackage[..., width=\the\cvrwidth, height=\the\cvrheight, ...]{crop}

Top 50 recent answers are included