{lengths} is for questions dealing with measurements in TeX. If your question is about the spacing between document elements, use {spacing} instead.

learn more… | top users | synonyms

142
votes
4answers
38k views

Difference between \textwidth, \linewidth and \hsize

The three lengths \textwidth, \linewidth and \hsize seem to all hold the width of the current line. At least I never saw some real difference between \textwidth and \linewidth in my code. Both seem to ...
8
votes
1answer
142 views

Measuring align

From what I read it seems that align environments are processed twice: the first time for measuring, the second time for actual typesetting. My question is whether one can get access to these ...
73
votes
2answers
40k views

Lengths and when to use them

There are many lengths in LaTeX. For instance, \enskip, \enspace, \quad, \parskip, \smallskip, ... Some of them are mostly used for vertical spacing, some others are mostly used for horizontal ...
40
votes
3answers
10k views

Get width of a given text as length

Is there a TeX command that returns the width of a given text as length value, so that I can use the result directly as a length argument of another command? I mean, I would like to have a command ...
17
votes
4answers
2k views

A line of length \textwidth in TikZ

Why does the following latex document: \documentclass{minimal} \usepackage{tikz} \begin{document} \noindent \begin{tikzpicture} \draw (0,0) -- (\textwidth,0); \end{tikzpicture} ...
16
votes
2answers
2k views

How to preserve the same parskip in minipage

I have following structure: \begin{document} Paragraph1. Paragraph2. \begin{minipage} Some paragraph1. Some paragraph2. \end{minipage} \end{document} How can I make the same spacing between ...
8
votes
1answer
231 views

How to compute exact width added by \left. \right

I have defined macros to produce resizable brackets that also work across line breaks. This necessitated the use of and additional set of \left. and \right. which add a bit of horizontal space. ...
9
votes
1answer
512 views

How does PDF or PDF Viewer define a rounding rule for stroke thickness?

I defined a sequence of line segments of different thickness each as follows. \documentclass{article} \usepackage{multido} \parindent=0sp \begin{document} ...
13
votes
3answers
2k views

Why doesn't \settoheight of \parbox work?

Consider the following code: \documentclass[a4paper]{letter} \usepackage{calc} \usepackage{printlen} \newsavebox{\foobox} \newlength{\fooboxheight} \savebox{\foobox}{ ...
4
votes
2answers
706 views

Is there a command to convert cm to bp?

I want to convert a length in cm (centimeter) to bp (big point). Is there a command to convert cm to bp?
28
votes
3answers
628 views

Is there a picture showing all the lengths used in lists?

I want to adjust the length parameters in a list (happens to be to make it more condensed, but that's not relevant). I do this infrequently enough that I don't remember all the lengths that are ...
20
votes
3answers
2k views

How do I get the exact dimension of a picture in LaTeX?

This question is pretty simple: I'd like to have the possibility to get the exact size of a picture in LaTeX with, for example, the macro \the. In fact, I've founded the way \settoheight{} and so on, ...
37
votes
2answers
2k views

Is there a \show for lengths?

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 ...
22
votes
5answers
6k views

How can I change the indentation in quote and quotation environments and commands?

I need to change the indentation that the quote and quotation environments and commands employ. I assume that there is some length I need to set, but I've googled around, and cannot find what I am ...
19
votes
2answers
2k views

What are the differences between \newdimen, \newskip and \newlength?

What are the differences between \newdimen, \newskip, and\newlength? When should I use each of them? Please give me a non-trivial example for each case.
12
votes
2answers
860 views

Where is the left-hand margin?

I'm working on the TikZ-from-TeX-SX package, specifically developing the code for putting equation numbering at places within a tikzpicture environment. To do this, I need to know where the text ...
14
votes
4answers
1k views

Conversion pt to mm or cm

Is there any way how to convert pt to mm or cm in plain TeX?
8
votes
2answers
4k views

Getting length as number?

I have probably formulated the question wrong, as I don't know the Tex internals - but this is what I mean; consider this example: \newcommand{\myNum}{2} \newlength{\myLength} ...
8
votes
1answer
2k views

Minimum length for \xrightarrow

I want to place text over arrows. The obvious choice is to use the amsmath command \xrightarrow{#1} However, sometimes the text above may be a single digit: %Example 1 \xrightarrow{1} other times ...
6
votes
1answer
208 views

Usage of a saved dimension in another saved dimension in a \pgfdeclareshape command

I have a question about \saveddimen usage inside of a \pgfdeclareshape command. My code is as follows: \documentclass{article} \usepackage{tikz} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % ...
3
votes
1answer
146 views

Settting PGFplots axis environment options by means of \newcommand and {\newlength,\setlength}

Because I often use the same options for multiple axes in my LaTeX documents, I use the following code to simplify my life. \documentclass{article} \usepackage{pgfplots} ...
15
votes
2answers
2k views

What is the difference between \def and \newlength?

I wrote the following LaTeX documents. \documentclass[11pt]{book} \newlength{\mywidth} \newlength{\myheight} \setlength{\mywidth}{85mm} \setlength{\myheight}{112mm} \newcommand{\setpagesize}[2]{% ...
10
votes
1answer
736 views

Why do \setcounter and \addtocounter commands have global effect, while \setlength and \addtolength commands obey the normal scoping rules?

The \setcounter and \addtocounter commands have global effect, while the \setlength and \addtolength commands obey the normal scoping rules. Why were they designed like this? Why are ...
9
votes
2answers
1k views

How to enable use of minus and plus in tex documents?

I see many cls files using plus and minus operators to set lengths. How can I use these operators (or some equivalent macro(s)) to do something like the following? \setlength{\lengtha}{.5\textwidth} ...
2
votes
2answers
859 views

Length parameter for vertical skip space in a math environment?

I learned here that I can use \\[<len>] to explicitly set the vertical skip space between lines, e.g., <len> set to 3ex. I'd like to set <len> to, say, 2-times the normal length in ...
22
votes
5answers
348 views

Test if a given control sequence is a length register

I'm in need of a macro which receives a control sequence as argument and needs to branch if this macro is actually a length (of any kind, e.g. dimen, skip etc.) or "just" a normal macro (including one ...
12
votes
1answer
2k views

Tikz - move/reposition arrow decorations (arrowhead length/size)

I'm trying to build a 'dimension line' macro for Tikz: \documentclass{article} % note: with \documentclass{minimal}, this example fails with: % ! Undefined control sequence. % ...
11
votes
5answers
738 views

Push/Pop or save a length/dimension?

Is it possible to push or pop a length like parindent? I want to change it temporarily but reset it soon after. I have a solution but looking for something a little nicer. I'll post it as an answer.
17
votes
2answers
16k views

What is the difference between `\hspace*{\fill}` and `\hfill`?

In the memoir manual on page 183 ,this example is given: \begin{figure} \centering \hspace*{\fill} {ILLUSTRATION 1} \hfill {ILLUSTRATION 2} \hspace*{\fill} \caption{Example float with two ...
21
votes
2answers
623 views

Which is better: a dimension or a macro?

When messing around with TikZ/PGF then I frequently find myself wanting to store a length for later use. By "length" here, I mean the word in its non-TeX meaning. As I'm doing stuff in TikZ/PGF then ...
11
votes
2answers
3k views

How to use \widthof as parameter to \kern

I sometimes encounter a problem when I attempt to use \widthof from the calc package, and don't know why. In the past I have just worked around it using a two step process of defining a \newdimen{} ...
9
votes
1answer
2k views

How to fix TikZ node's height with \heightof?

I can use \widthof{text} to fix a minimum width of a TikZ's node. I would like to use \heightof{text} to fix its minimum height but it doesn't work. I just want to fill my nodes with one word but I ...
7
votes
4answers
270 views

Function determining the length of text, usable where something with internal units (e.g. “em”) is expected

Is there a way to define a function \horizontallengthof returning the length of a piece of text in internal units? I would like to be able to use it anywhere where something of that sort is required, ...
11
votes
3answers
509 views

Measure the length of the lowercase alphabet

In the memoir manual speaks about measuring the length of the lowercase alphabet in order to decide the numbers of characters per line. Can this be done with LaTeX?
9
votes
2answers
233 views

Compute remaining horizontal space in align environment

I use align* often and sometimes it is preferable to add text to the right hand side of an equation instead of using \intertext, or \shortintertext, which tends to interrupt the math flow. This is ...
9
votes
2answers
741 views

What is the plain TeX equivalent of \settowidth?

The \settowidth command, which sets a width equal to the width of some text, is described at Get width of a given text as length and How to set the width of the label of a description to the width of ...
9
votes
2answers
253 views

Confused with whether or not I have to use \the

I got confused with whether or not I have to use \the. \the in \special{papersize=\the\paperwidth,\the\paperheight} is mandatory. But \the in neither ...
7
votes
3answers
176 views

Vertically center image with text midpoint

I want to vertically align the center of an image with the vertical center of the text on the same line using \raisebox. Using a macro is a must since it will be used many times (and multiple times on ...
7
votes
4answers
933 views

A macro that expands to the length of its argument

If I want to anonymise a paper I've written for review, I don't just want to delete my name from the author field. I want to replace my name with a rule as tall as a capital letter and as long as my ...
6
votes
1answer
613 views

How to align underlined text and a horizontal line created with \rule

As described in this question I'm using the tocloft package to customize the table of contents. We are putting a horizontal line under the whole section text up to the page number. Therefore we ...
5
votes
1answer
534 views

TikZ, foreach and sum

I'm trying to create a list of rectangles of various sizes, starting at the end of the previous rectangle. I'm using a foreach loop with a TeX length, but I don't get the result I want, and I really ...
4
votes
2answers
373 views

Visual debugging of lengths in paragraphs and environments?

During my searches, I found a couple of online images, which I doubt are produced with Latex - however, I found them immensely useful in understanding what is going on. I'm pretty sure the images ...
10
votes
2answers
96 views

Convert from physical dimensions to axis cs coordinate values

In answering PGFPlots: Howto draw a label at a zero of a function?, I got stuck on converting a length in pt to the actual coordinate value in the axis cs system. Here I only need the x value, but ...
9
votes
2answers
328 views

Page geometry discrepancies

In the Companion 2nd Edition Table 4.2 shows page geometry values for various font sizes of the letterpaper paper size. These differ sometimes substantially from current values of the standard ...
9
votes
2answers
363 views

How can I globally set pgfmathsetlength?

How can I declare a length via pgfmathsetlength global? The example results in 20pt -- 5pt -- 20pt But I had expected: 20pt -- 5pt -- 5pt \documentclass[10pt]{article} \parindent0pt ...
9
votes
2answers
2k views

What is the difference between \fboxsep=1cm and \setlength{\fboxsep}{1cm}?

Question has been written above.
9
votes
3answers
373 views

Making register declarations local, Undefining a register (count, toks, etc.)

Is it possible to make \newcount, \newtoks, etc. respect grouping, so that, e.g., \newcount\temp\temp=2{\newcount\temp\temp=1}\showthe\temp gives 2 (instead of 0)? Relatedly, is it possible to ...
6
votes
3answers
385 views

How to detect the length of the tallest letter and that of the deepest letter of the current font size?

My idea is to redefine the \strut to be as short as possible. It means the length of strut is the sum of the tallest letter length and the deepest letter length.
5
votes
1answer
162 views

How to preserve lenghts to use with \includegraphics scaling, when calculating them with pgf

This question is related to my earlier question here: How to define a macro that uses image width and height to define a variable for later use . There you can find a full MWE of the problematic code. ...
4
votes
1answer
76 views

Writing to and extracting from aux not working?

Consider the following MWE: \documentclass{article} \newlength{\templen} \makeatletter \AtEndDocument{% \immediate\write\@auxout{\noexpand\setlength{\noexpand\templen}{150pt}}} \makeatother ...