The \show command is extremely useful for figuring out what's going on with a particular macro. Similarly, using \the can tell me the value of a counter. I'd like to know if there's something similar for lengths and skips. At the moment, I end up doing something like \rule{1pt}{\unknownlength} but that's a fairly crude method.
Asked
Active
Viewed 1.2k times
63
Andrew Stacey
- 153,724
- 43
- 389
- 751
2 Answers
63
To show registers (which include dimensions, skips and counts) you want \showthe.
Joseph Wright
- 259,911
- 34
- 706
- 1,036
-
16Given that there's \show, \the, and \showthe; I'm left wondering what \theshow does. Frivolity aside, thanks! – Andrew Stacey Jul 29 '10 at 10:50
-
12'Undefined control sequence!' :-) – Joseph Wright Jul 29 '10 at 11:14
-
2See https://tex.stackexchange.com/questions/345185/difference-between-the-showthe-and-show-commands for some examples of \show, \the, \showthe – mrupp Sep 16 '20 at 13:49
-
1If anyone else was confused. This causes pdflatex to break compilation and tell you the value -- so if you have a build script it may cause it to fail. It doesn't print it out in the document. – Caleb Stanford Jul 08 '22 at 22:15
63
Somewhat more friendly than \showthe, which returns lengths in pt, is the printlen package. It gives \printlength{...}, which will typeset (so it's actually more like \the I guess) the length in the units specified by \uselengthunit. E.g., from the documentation:
The \verb|\textwidth| is \printlength{\textwidth} which is also
\uselengthunit{in}\printlength{\textwidth} and
\uselengthunit{mm}\printlength{\textwidth}.
Joseph Wright
- 259,911
- 34
- 706
- 1,036
Will Robertson
- 73,872
-
This is one of those cases where it'd be nice to be able to accept both answers. Thanks for taking the time to add the extra information. – Andrew Stacey Jul 29 '10 at 11:05
-
@Andrew: Interesting feature request: allow accepting both answers, splitting the 15 points of acceptance between the accepted answers....Meta? – Yossi Farjoun Jul 29 '10 at 11:41
-
@Yossi Farjoun: We debated this on MO a bit and decided that it wasn't worth the hassle. In this case, Joseph was first and in practice his is the answer I am most likely to use so the acceptance is defendable. Given that rep isn't quite everything, I hope that my first comment (and vote) is sufficient thanks from me to Will. It only takes two votes from other people to give him more rep than the accepted answer tag would have done so I hope that enough will vote here that he won't feel hard done by. – Andrew Stacey Jul 29 '10 at 11:52
-
@Andrew: I looked this up on meta.SO where they had a discussion of this before. Basically, the idea is that one question has either one correct answer or none....I guess, an good answer will be voted up regardless if it accepted or not. – Yossi Farjoun Jul 29 '10 at 12:53
-
1@Yossi Farjoun: Hmm, the mathematician in me wants to say that a question can have several right answers, but that one will be more right than others in a specific situation. I think that your last remark is spot on. (And I think that we should get out of Will's "comment list"! If there is anything further to say on this - which I don't think there is - it should be shifted to meta.) – Andrew Stacey Jul 29 '10 at 13:02
-
Don't worry too much about the accept thing :) especially in this case it's just addition information. – Will Robertson Jul 29 '10 at 13:44
-
Seems
\printlengthis not expandable, so I used printlen.sty to be able to typeout values via internals; say, for\oddsidemarginin "cm" :\makeatletter \setlength{\@tempdimc}{\l@nunitperpt \oddsidemargin\relax} \typeout{\the\oddsidemargin, \strip@pt\@tempdimc \l@nunits} \makeatother– sdaau Jun 06 '12 at 22:19