Questions tagged [lengths]
{lengths} is for questions dealing with measurements in TeX. If your question is about the spacing between document elements, use {spacing} instead.
124
questions
411
votes
4answers
308k 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 ...
309
votes
2answers
350k 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 ...
169
votes
4answers
61k 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 \...
48
votes
2answers
9k 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 ...
75
votes
2answers
204k 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 ...
11
votes
1answer
239 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 ...
22
votes
4answers
5k 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}
\...
39
votes
3answers
3k 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 ...
55
votes
2answers
9k 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 ...
26
votes
4answers
10k 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}
\setlength{\myLength}{\...
26
votes
3answers
14k views
How do I control 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, ...
10
votes
1answer
856 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.
Now, ...
9
votes
3answers
760 views
Defining a Length that Scales with Fontsize Changes
I noticed a behavior regarding lengths under fonstsize changes, which I'm hoping there is a way to circumvent. Consider this MWE:
\documentclass{article}
\begin{document}
\newlength\mylength
\...
50
votes
5answers
23k 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 ...
8
votes
1answer
2k views
How to get width of equation
If I want to know the width of a text I use
\settowidth{\MyLength}{bla}.
Is there something similar for equations?
More specifically I have
\begin{align}
a & b & c & d\\
c & d &...
4
votes
2answers
2k 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?
20
votes
4answers
770 views
Scaling a glue in TeX
is there a possibility to scale a glue in TeX? Consider the following example:
\newskip\foo
\newskip\bar
\foo=10pt plus 2pt minus 3pt
\bar=2.5\foo\relax
\showthe\foo
\showthe\bar
\bye
When feeding ...
19
votes
2answers
2k views
How to have a precise control on the size of each page?
I would like to produce a pdf document whose pages have various lengths and fixed widths.
An easier situation
The easiest case would be for instance: the first page has a length of 10cm all the next ...
34
votes
2answers
8k 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.
16
votes
2answers
2k 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 ...
27
votes
1answer
14k views
Get current font size as length
I understand from THIS question that the current font size can be determined.
But how can I convert this to a length value?
\documentclass[10pt,a4paper]{article}
\newlength{\mytextsize}
%This ...
16
votes
5answers
3k 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.
8
votes
4answers
2k 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, ...
15
votes
2answers
6k 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 ...
16
votes
3answers
3k 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}{
\parbox[t]{\textwidth}{...
15
votes
4answers
4k views
3
votes
2answers
3k 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 ...
2
votes
3answers
2k views
How to setup a longtable with booktabs and a colored (head) row
I'd like to make a longtable with the first (head) row colored in grey.
Since booktabs inserts white space below the \toprule and above the \midrule, i need to insert a colored rule:
\newcommand*{\...
53
votes
4answers
67k views
Determine text width
For sizing figures in LaTeX it's helpful to know how wide the text is so that figures can be sized to match without rescaling. LaTeX provides \textwidth for reference by other commands, e.g.
\...
27
votes
3answers
10k views
How can I know the default PGF line width?
Is there some macro that will tell me what the default PGF line width is? I have tried creating my own macro by cloning \pgflinewidth before it has been modified, i.e.
\let\defaultlinewidth\...
16
votes
1answer
22k 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 ...
37
votes
2answers
22k 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]{%
...
5
votes
1answer
4k views
A tcolorbox centered and automatically adjusted to the current text size
Consider the following code:
\documentclass[a4paper, 10pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage[listings,skins,theorems,breakable]{tcolorbox}
\usepackage{lipsum}
\usepackage{...
12
votes
2answers
1k views
Convert from physical dimensions to axis cs coordinate values
In answering PGFPlots: How to 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 my ...
12
votes
2answers
677 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 ...
10
votes
2answers
4k views
Decrease length of underscore character in normal text (gender_gap)
I use the underscore character _ in normal text mode (not typewriter). However, it is quite long. How can I decrease its length so that it is shorter?
I followed the Tex FAQ on how to typeset an ...
3
votes
1answer
2k 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}
\newcommand{\linecolora}{blue}...
11
votes
3answers
562 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 ...
5
votes
2answers
668 views
Defining macro \gsetlength as global setlength, reliable?
As is noted in other questions, such as Global scope or permanent length or savebox, the \setlength command does not always have global effect. In many cases, that is desirable. But when the effect ...
5
votes
2answers
1k views
How to use \textwidth (or any variable) in a picture environment
I don't understand why this doesn't work. I am getting a compile error. Am I missing something?
\documentclass[12pt,a4paper]{article}
\begin{document}
\begin{picture}(0,0)
\linethickness{1....
4
votes
2answers
105 views
calc package and global lengths problem in tabularx
The output of the following code is affected whether calc package is included or not:
\documentclass{article}
\usepackage{tabularx}
% \usepackage{calc}
\newsavebox{\testbox}
\newlength{\testlen}
\...
29
votes
3answers
1k views
Make my infinite squares math-proof
I created a command that makes a square of text in ever-decreasing sizes to create the effect of infinite decrease. But if I increase the starting width, or change the scale factor, TeX has an ...
37
votes
2answers
1k views
What is truecm?
In examples found around the web, some people specify lengths such as width=5truecm with \includegraphics or the geometry package. How is this different from regular 5cm?
12
votes
1answer
923 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}
\multido{\dx=0sp+1000sp}{100}{\rule{0.01\...
12
votes
1answer
5k 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.
% \pgf@lib@dec@computed@...
21
votes
1answer
1k views
Is there an `ex` unit equivalent for the capital 'X' in LaTeX
In LaTeX, the ex unit represents the height of a lowercase 'x' in the current font.
Is there a length in LaTeX that represents the height of a capital 'X'?
13
votes
2answers
2k 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 ...
12
votes
2answers
9k views
How to calculate a new length?
What I want to do is calculate the actual size between the edge of the paper, and my header. \evenmarginsize and \oddmarginsize do not do this.
\settowidth{\msize}{((\paperwidth - \textwidth)/2)}
...
11
votes
1answer
12k views
How do you increase headrule length in fancyhdr?
It's pretty well-known how to increase the headrule width, but how do I increase its length (i.e. let it run into the margin).
13
votes
1answer
2k 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 \setcounter ...