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.

Filter by
Sorted by
Tagged with
7
votes
1answer
137 views

create spacing command that eliminates extra spaces after

After a \section command, there is the same amount of space regardless of what follows. An itemize environment does not add extra space. How can I achieve the same behavior after a custom environment?...
7
votes
1answer
694 views

\parskip stretches more than expected

I wonder if I get something wrong with TeX’s glue concept. If define a length to be 2pt plus 1pt minus 1pt I expect that the length should be exactly 2pt where possible an if not it should be between ...
7
votes
2answers
1k 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 ...
6
votes
3answers
454 views

How to get depth and other lengths of a font?

Red line in the output is \baselineskip, the only length in question that I know of. The output image provided here is an edited image in which (red line representing \baselineskip is re-positioned to ...
6
votes
3answers
536 views

Comparing calculated real numbers

"\ifdimless" can compare two real numbers. But, how can we feed the result of a calculation to this function ? \documentclass[]{article} \usepackage{tikz} \usetikzlibrary{calc} \usepackage{etoolbox} ...
6
votes
3answers
1k 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 ...
6
votes
2answers
296 views

Why \newlength is not profiled as \newcommand?

While commands are defined and set in one step with \newcommand, lengths need two steps for this: \newlength and then \setlength. Because \newlength{\foo}{1cm} would be easier than \newlength{\foo}...
6
votes
1answer
701 views

What does a number followed by “ in” mean?

The TeX syntax highlighter that I use colors all occurrences of a number followed by " in", e.g. 0 in or 32 in in a dangerous bright red, in almost all contexts. Why?
6
votes
1answer
1k views

retrieve the length of a segment

I want to retrieve the length of a segment in cm for display in a node As in the example below, I would like to display the length of three vectors \documentclass{article} \usepackage{tikz} \...
6
votes
2answers
413 views

TeX/LaTeX: Macro for getting a length as number

I would like to write a macro getlengthin to get a length or dimen as floating point number in a specified unit. Here is what I have created so far: \documentclass{article} \usepackage[nomessages]{...
6
votes
1answer
2k views

\columnwidth in cm

I have a silly question - i am using double column style \documentclass[english,a4paper,12pt, openany]{book} When I add a figure I usually put in \columnwidth and just let LaTeX to stretch it to the ...
6
votes
1answer
315 views

Exact Fraction of a length

I want to place some elements on my page for which I need to calculate their size. For my example lets say three of those elements should exactly occupy a \linewidth when put side by side without ...
6
votes
1answer
455 views

LuaLaTeX: Calculate length in Lua

I apologize if this a rookie question, but I find it extremely hard to find a solution to my Lua problem using online searches and browsing reference manuals. I would like to calculate a length: ...
6
votes
1answer
364 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} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \...
6
votes
1answer
944 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
2answers
3k views

Draw parallel lines each one with a fixed length

I am trying to create parallel lines in tikz. Although I can create those lines, I can't seem to be able to control the length of those lines, which I want them to stop in the red box's face. My code ...
5
votes
2answers
179 views

Can you add a constant value to a length macro?

I have a box that's the full width of the page. I would like to offset it back into the margin a little, but when I do that it no longer reaches the edge of the page. Is it possible to keep using a ...
5
votes
2answers
13k views

What is the default length of \hrule?

When used without parameters, what varfiable controls the length of \hrule? I.e., how can I change the default length of \hrule, other than adding parameters to each instance -- say, to affect ...
5
votes
1answer
953 views

Is it possible to remove length, counter, dim, etc that have been declared?

Let's see the following screenshot taken from an answer of Efficient ways to anonymize a document and the given comment. Is it possible to remove length, counter, dim, etc, that have been declared in ...
5
votes
1answer
1k views

em, ex, en? Which length units are font size dependent?

Length can be specified as 3em, or 3.5ex. What is required to make 4en also valid? Are there any other font related length units?
5
votes
2answers
950 views

Dante Monotype typeface and fractions

I am handling a text which is natively written in a proprietary LaTeX documentclass which implements Dante Monotype fontface. In this text there is a lot of maths and I would say that it works, ...
5
votes
3answers
153 views

What is the correct calculation to span some columns?

I want to create a column spanning 5 columns with m column specifier. It seems my calculation \multicolumn{5}{m{5\temp}|}{\hrulefill} is wrong as the rule does not occupy the left space. What is the ...
5
votes
2answers
557 views

How to calculate the width of a space?

Using the questions: Get width of a given text as length Lengths and when to use them enumitem package and description lists For the inline enumerate: controlling the item spacing Customizing inline ...
5
votes
3answers
498 views

Multicolumn within tabularx: how to get p{'lengths'} right

I am trying to have the lipsum text fill the two cells to the right of the vertical ruler, without exceeding the table. My code is now: \documentclass[a4paper,11pt]{article} \usepackage{lipsum} \...
5
votes
2answers
791 views

Set length to the line height of a particular font

How to define new length using : \newlength{...} \setlength{...}{...} and equal to the line height of a particular font (for example \tiny\ttfamily) Note : I want a solution which does not involve ...
5
votes
2answers
80 views

How to set a distance that rescales with the font [duplicate]

I'm trying to set a distance which is relative to the font size. The problem is that the distance is reused several times in the document, potentially in environments with a different font size. In ...
5
votes
1answer
451 views

What's the meaning of the command \number and when to use it? And some confusion about the following code

\setcounter{numofgaps}{\numexpr\number\value{numofboxes}-1} \setlength{\truetextsectionwidth}{\textsectionwidth-\number\value{numofgaps}\gapwidth} The above code is a snippet from the answer of How ...
5
votes
1answer
691 views

How to log the value of a variable?

I am debugging a set of macros. The error seems to come from \vspace*{\dimexpr0.000000cm-\topskip plus 1fill}. How can I log the value of the length? I have tried \typeout{\dimexpr0.000000cm-\...
5
votes
2answers
136 views

Free - dereference - release - delete a newdimen length?

Somewhat similar to How to erase/delete a counter, I guess, but for \newdimen... So, consider the MWE: \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \...
5
votes
2answers
868 views

Measuring line length, using \hfill to justify text, wrapping and right justifying if space too small

I am a lecturer and have an issue when compiling test and exam questions. The questions will be in an enumerate environment and look something like this, where the marks shown in brackets are right ...
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....
5
votes
1answer
220 views

How can I compare the width of a paragraph to 45% of the linewidth?

Here's my pseudo latex code to try and show what I'm trying to do in my memo latex class: \newcommand\headername{%should be the @memoto, or if too long, an abbreviated subject \ifthenelse{\...
5
votes
2answers
177 views

Measuring List Items in Tasks and Making Changes Accordingly

I made the following list for MCQs using taskspackage. The problem is I need a command that can measure the contents of all the \tasks per question and determine the maximum width among them. And in ...
5
votes
1answer
164 views

If I need to set width to text width, how can I restore it later?

What is the syntax for storing some width in order to change it temporarily and then restore to the original? Example: %save length here \setlength\somewidth{\textwidth} some text \begin{...
5
votes
1answer
1k 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 ...
5
votes
1answer
332 views

How to pass the value of \mylength to the “trim” option of \includepdf of pdfpages.sty?

This problem is related to my previous problem about pdf trimming. Here is the minimal code: \documentclass{article} \usepackage{pdfpages} \usepackage[paperwidth=6.38in,paperheight=4.025in,margin=...
5
votes
1answer
433 views

Arithmetic/calculations with lengths

I want to define a new command to add vertical "padding" before and after the content of a table cell. I'm stealing the idea of using rules/struts from the accepted answer to this question. My ...
5
votes
1answer
790 views

Use dimensions \totalheight \depth for inline TikZ drawing

I want to use the current text's dimensional properties for constructing an inline TikZ image, such as an icon. The properties I have in mind for use are \height \depth \totalheight as described ...
5
votes
1answer
93 views

How do I forward a length from a command into a column specifier?

I'm using longtable where I want vertical bars separating cells, although not for the table headers. I have 8 columns (but show only 3 here as example) and want to re-use the same lengths on the main ...
5
votes
2answers
3k views

fontsize setting with newcommand and newlength

How do I set a \newcommand so that the field #1, which is calculated to be 1.2*#2 Optional? Something similar to the following commands, but that did not work. \documentclass{article} \usepackage[...
5
votes
2answers
121 views

Splitting bibliography alphabetically: how to vertically align margin note?

Context: Since my bibliography is constituted of 200+ entries, I want to add margin-notes at each new letter to split the bibliography alphabetically. (I.e., print a "B" in the margin next to the ...
5
votes
1answer
4k views

algorithm2e and \algomargin with negative value

How can I use a negative length in \algomargin using algorithm2e? I get the unpleasant effect that the vertical lines and the caption are not moved accordingly, see for example: Note that this image ...
5
votes
1answer
141 views

Using lengthconvert with siunitx S column

I need to align numbers in a table. The numbers are generated from the \Convert command from the lengthconvert package. I want to use an S column from the siunitx package to align the numbers, but ...
5
votes
1answer
273 views

How can I readjust TikZ's dimension variables to fit mid-document dimension change?

Question How can I readjust TikZ's dimension variables to fit a mid-document dimension change as in this example and using the TikZ drawing from here. Problem TikZ coordinates are not where they ...
5
votes
1answer
370 views

How do I access the width of text from the preamble?

I've got some macros that I want to set up in my preamble. The problem is that they need to know what the width of a typical line of text will be in the document. If I do something like, %% ...
4
votes
3answers
415 views

angled lines of unkown length in TikZ

I am trying to create angled lines from a point to specific border. Here is a minimal example: \documentclass[margin=2mm]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \...
4
votes
2answers
3k views

Problem with \makebox and the unit in the dimensions

I want to superpose a text to some other object (in this aces a picture). My idea is to store the picture in \mabox, to display it with in a \makebox with 0 width and height, then to display the text ...
4
votes
3answers
3k views

Access height of a \parbox

Within a \parbox I can access its width via \linewidth (useful e.g. if I want to place an image as wide as the \parbox). Is there a way of accessing the height of a \parbox when the height is fixed ...
4
votes
2answers
766 views

Draw a line under a figure that match the figure lentgh

I am using a line under a figure to make it more aesthetic. I am having a problem with matching the line length with the figure length. Here's a MWE. \documentclass{article} \usepackage[utf8]{...
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?