Questions tagged [dimension-expressions]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3 votes
2 answers
238 views

Default units in expl3

So I have produced code, which I think is kind of a hack, but it seems to work so far in my testing. I have setup a new expl3 function that sets a dimen variable. If the input for the dimen expression ...
User23456234's user avatar
  • 1,727
11 votes
1 answer
576 views

Don't stress yourself: relax in skips in math and text modes

Relax and exhale I'm accustomed to seeing \relax at the end of many macros. Often, I don't understand the rationale; sometimes the placement seems more or less arbitrary to me. For example, computing ...
user avatar
0 votes
1 answer
64 views

Extend the height of parbox

I have the following command that prints text in the margins: \DeclareRobustCommand{\solutionpage}[1]{\marginpar{% \colorbox{lightgray}{\protect\parbox[t]{\dimexpr\marginparwidth-2\fboxsep}{~Proof ...
tush's user avatar
  • 1,115
3 votes
2 answers
142 views

Difference between \skipeval and \dimeval

What is the difference between \skipeval and \dimeval? They appear to produce the same result, but perhaps \dimeval removes the glue? \rule{\dimeval{ \linewidth plus 1cm minus 1cm - 1cm}}{1pt} a\\ \...
likethevegetable's user avatar
2 votes
2 answers
75 views

How to correctly write a command/macro which returns a dimension

I am trying to write a command/macro which would return a dimension that can be used to configure an environment I've created. For example I have a TwoColumn environment where I want to include a ...
Matthew Fong's user avatar
2 votes
1 answer
125 views

\dimeval for pdflatex?

I'm using pdfTeX 3.141592653-2.6-1.40.22 (TeX Live 2022/dev/Debian). In a recent question, I have been provided with two excellent answers that unfortunately both make use of \dimeval. This command is ...
vwegert's user avatar
  • 2,865
1 vote
1 answer
31 views

Can I change font based on predicted width

Is it possible to define a macro that changes font based on width that a box "would be"? I'd like to define a LaTeX macro that does something like: \newcommand{\mylabel}[1] { \if\...
user3486184's user avatar
7 votes
2 answers
1k views

How to divide in LaTeX without it rounding or truncating?

I'm working on a diagram and I'm pretty new to LaTeX, so I've decided to try to do it using math instead of statically assigned values. I have come up with the following: \newcommand\qoffset{14} \...
Taggagii's user avatar
0 votes
1 answer
56 views

How to properly halve the inter-line distance in a math block environment

... of amsmath or mathtools? In other words, how to properly halve \jot? Options: \setlength{\jot}{.5\jot\relax} \setlength{\jot}{\dimexpr.5\jot\relax} \setlength{\jot}{\dimexpr\jot*.5\relax} \...
user avatar
4 votes
2 answers
252 views

Why doesn't \dim_eval:n return appropriate result and behaves weirdly?

All I needed to do is divide 300pt by 5mm to get result either in pt or in mm units. But I got something else. \documentclass[varwidth]{standalone} \usepackage{expl3} \begin{document} \ExplSyntaxOn ...
bp2017's user avatar
  • 3,746
3 votes
1 answer
2k views

How to control white-space dimensions around author block with authblk and geometry?

I am trying to control the white-space dimensions around my author block using authblk and geometry. How can I control the distance between the top margin and the title, the title and the author list,...
Canaryyellow's user avatar
1 vote
1 answer
149 views

Is `\strip@pt` removing the hundreds as well as the `pt`?

I was getting some strange results trying to position things in beamer, and I realised that \strip@pt was removing not only the pt, but also the hundreds from the number. Here's my MWE: \...
craq's user avatar
  • 371
0 votes
1 answer
121 views

Moving a TikZ drawn `mdframed` `frametitle` box vertically by a real amount?

Consider the following MWE: \documentclass{article} \usepackage[framemethod=TikZ]{mdframed} % noteboxes, boxes, etc. \usepackage{calc} \newcommand{\definebox}[2]{% \newcounter{#1} \...
bzm3r's user avatar
  • 3,186
1 vote
1 answer
116 views

Dimension too large problem tizpicture

I'm a beginner with LaTeX. I use matlab2tikz to create a bar figure, but in LaTeX always shows Dimension too large.end{\axis}. I have no idea about that. \begin{tikzpicture} \begin{axis}[% width=4in,...
Superzhen's user avatar
11 votes
2 answers
4k views

Divide two lengths

How do I divide two lengths and get a length out? \documentclass{article} \newlength\A \newlength\B \newlength\C \setlength\A{10pt} \setlength\B{5pt} \setlength\C{\dimexpr\A/\B\relax} \begin{document}...
Carucel's user avatar
  • 1,035
4 votes
3 answers
2k views

`\dimexpr` with multiplication by real number and with parenthesis

I wish to draw an object with tikz by a macro, therefore I have to calculate expressions like: defined by: \newcommand{\myhexagon}{2}{...} \newcommand{\myobject}{2}{ \myheaxgon{#1}{0.5*#2} \...
Tom Solid's user avatar
  • 837
3 votes
1 answer
350 views

How to typeout dimexpr?

I'd like to debug some width problems in the following code, but the \typeout prints commands instead of actual value: \documentclass{article} \usepackage[margin=3cm]{geometry} \usepackage{array} \...
Velkan's user avatar
  • 165
3 votes
1 answer
189 views

Why do I need \fp_to_dim:n in my dimension expression?

I’m trying to use an expel floating point variable (\l_@@_last_machine_row_x_fp) inside a calculation of a dimension (\l_@@_bar_width_dim). In the following code \BarA works (with a solution from this ...
Tobi's user avatar
  • 56.1k
1 vote
1 answer
390 views

Predefined lengths in \put

This works: \documentclass{article} \usepackage{eso-pic} \begin{document} \AddToShipoutPictureBG* { \setlength{\unitlength}{1 mm} \put(52, 240){Text} } Some more text \end{document} ...
user44413's user avatar
  • 601
6 votes
1 answer
767 views

How are dimensions converted in multiplication and division?

In the TeXbook it is said (page 118): Multiplication and division are possible too, but only by integers. ... Dimension values are integer multiples of sp (scaled points). Example 1. Result is ...
Igor Liferenko's user avatar
4 votes
1 answer
330 views

Why we used \number in Latex?

Here is my code: \documentclass{article} \makeatletter \def\Printdimen#1#2{\strip@pt \dimexpr #2 *65526 /\number\dimexpr 1#1} \makeatother \begin{document} \Printdimen{mm}{\hsize} mm \end{document}...
enadul shaheen's user avatar
5 votes
1 answer
623 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 ...
Yulong Ao's user avatar
  • 723
5 votes
4 answers
1k views

Add values stored in an array

\documentclass[a4paper,10pt]{article} \usepackage{arrayjob} \begin{document} \newarray\cws \cws(0)=3pt \cws(1)=4pt \let\a\dimexpr\cws(0)+\cws(1)\relax \a \end{document} Error: ! You can't use `\...
nagylzs's user avatar
  • 1,225
6 votes
2 answers
18k views

Trying to embed mp4 in a Beamer presentation

Sample document \documentclass{beamer} \usetheme{Amsterdam} \usepackage{media9} \title{TITLE} \author{AUTHOR} \institute{INSTITUTE} \date{DATE} \begin{document} \addtocounter{framenumber}{1} \...
Cornelius Mullens's user avatar
6 votes
1 answer
159 views

Why are my dimension calculations so far off?

I've got some macros storing information about various dimensions. When I start dividing by dimensions, though, I'm getting answers that don't make sense. \documentclass{article} \usepackage[...
A.Ellett's user avatar
  • 50.4k
5 votes
1 answer
3k views

Usage of the \dimexpr command

I have MiKTeX 2.3 and its version of e-TeX does not support \dimexpr command. I do not want to update this MiKTeX now and wonder, is it possible to define the \dimexpr command, probably with use of ...
user avatar
3 votes
3 answers
854 views

Problem with addition and macro argument

I need to use a formula like this: y = 1.8pt * x + 1.5pt inside a macro, where x is a scalar macro argument. My idea: \kern \advance #1\dimexpr1.8pt\relax by \dimexpr1.5pt\relax This doesn't ...
Emit Taste's user avatar
  • 4,394
8 votes
1 answer
2k views

dimexpr: multiplication with constant real factor from macro

I want to multiply a constant from a macro with a deimension using dimexpr. When using real numbers the decimal point and the decimal digits are typeset behind the result and the result is a ...
ted's user avatar
  • 3,367
7 votes
1 answer
1k views

Adding constant to function (vspace) argument?

How can I get Latex to add a constant to a value as part of a \vspace argument? Here's my minimal example: \documentclass{article} \usepackage{calc} \begin{document} ab %\vspace{20mm+10mm} %...
Stefan K.'s user avatar
  • 463
3 votes
2 answers
552 views

Undesired equal sign in beamer using \dimexpr

I'm using the following script in beamer to locate our logo at the right-most corner of all pages in the presentation, \begin{textblock}{5}(10.0, \dimexpr 0.5\headheight - 7.5pt ) \includegraphics[...
Sait's user avatar
  • 1,987
84 votes
2 answers
33k views

What are the possible dimensions / sizes / units LaTeX understands?

I know there are different ways of expressing sizes or dimensions in LaTeX such as points (pt), inches (in) and ex. As some commands, such as \hspace understand all of them, I would like to have a ...
Henrik's user avatar
  • 865
111 votes
9 answers
99k views

How can I sum two values and store the result in other variable?

In LaTeX2e,how can I sum two values and assign them to other variable? I want to compute something like: var=\textwidth - 1cm And if both were constants: var=1+1
mjsr's user avatar
  • 3,415
3 votes
2 answers
493 views

\dimexpr replacement/"expansion" without eTeX

I want to use \'{\i} in a bookmark. While it works without problems when eTeX is there, I cannot use e.g. \dimexpr without eTeX. (And the current version of my TeX distribution does not contain eTeX ...
Stephen's user avatar
  • 14.9k
1 vote
2 answers
1k views

What is the correct syntax to do arithmetic for length and dimensionless macros?

I want to set papersize based on PSTricks settings. The PSTricks settings may be a value without dimension and/or a value with dimension. Honestly I have not read the TeXBook because of my laziness. ...
Display Name's user avatar
  • 46.9k
20 votes
4 answers
2k views

Why does \dimexpr swallow \relax?

Following the comments at Doing maths with distance values in LaTeX source code: +1 for teaching me that \dimexpr can optionally swallow a \relax. Yesterday I tried to use \relax as a delimiter for \...
Charles Stewart's user avatar
5 votes
3 answers
573 views

LaTeX3: \dim_eval:n and e-TeX dimension expression

Why does the following code not yield the expected result 264pt? Are non-integers not allowed as factors in e-TeX dimension expressions? \documentclass{article} \usepackage{expl3} \begin{document} \...
AlexG's user avatar
  • 54.7k
2 votes
2 answers
355 views

LaTeX3: \dim_set:Nn with l3calc or calc type dimension expression

I am getting an error when I try to set a dimension register with a l3calc/calc type dimension expression using LaTeX3 \dim_set:Nn command. Even wrapping the whole expression into \dim_eval:n{} doesn'...
AlexG's user avatar
  • 54.7k