# Tag Info

3

The \titlespacing command uses some tricks for extracting the plus and minus dimensions and doing some computations; the \relax token disturbs the processing, because \relax is used as terminator of an argument in one of the internal macros. \documentclass[11pt,a4paper]{book} \usepackage{lipsum} \usepackage{titlesec} \newlength{\textsize} \makeatletter ...

1

@egreg answer is correct but in the community is hard to convince others (reluctant-TeX) collaborators to use \mbox{\normalfont\AA} or \text{\normalfont\AA} to write Angstrom units. At best one can hope that they use \mathrm{\AA} (so Angstrom doesn't appear as italic in math formulas). They are just to used to write \AA. What I suggest is this: ...

4

Assuming you want input syntax \unit{kg}{m} what you need to do is use the TeX primitive \futurelet to search for an upcoming {. If there is one, we can grab a (braced) argument, typeset it in math mode then loop. Note that this approach requires braces around each argument. \documentclass{article} \makeatletter \def\unit{% \$% ...

4

The problem when you do \def\@unit#1 is that the argument will never be the brace, but all that goes from the open brace to the matching closed one and your test is never successful. You can do it with \futurelet, but you'll be tied to a very inflexible system of input. Here's an expl3 implementation that's possibly clearer than \futurelet. ...

17

For the sake of completeness, one option is to just do the unit conversions in LaTeX, using something like pgf/tikz or fp. I am personally of the opinion that this isn't an ideal solution, since there are a lot of edge cases (like, for instance, when to convert between meters and kilometers, or how much to round). It may be sufficient for a nonscientific ...

24

Implementing your hack is quite easy: \newif\ifMetric\Metrictrue% metric by default \newcommand\MyUnit[2]{\ifMetric #1\else #2\fi}% \MyUnits{metric}{imperial} Then you can simply use \MyUnit{191cm}{6'3''} in your document and change between metric and imperial at any point using \Metrictrue and \Metricfalse. Here's a full example (with a crude use of ...

Top 50 recent answers are included