Questions tagged [calc]
The calc tag has no usage guidance.
87
questions
1
vote
2
answers
76
views
Weird behavior of \setlength
I wish to use the code below in order to get the maximum length of a list of words.
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usepackage{calc}
\begin{document}
\begin{tikzpicture}
\...
1
vote
1
answer
43
views
fontspec's \addfontfeatures messes with calc's \widthof
In addition to Werner's answer, I would also like my list labels to use tabular numbers.
I would have thought that the first approach below would work, but the list labels are slightly in the left ...
2
votes
3
answers
152
views
LaTeX calculator with variables and number substitution
Is there a calculator with variables and number substitution with LaTeX syntax?
Here is an example:
First I set the variables:
m_\text{груза} = 5
h = 2
g = 9,81
Next, I write the equation to be ...
1
vote
2
answers
52
views
Error with a command whose purpose is to allow a value to adapt over the course of a document
I am trying to write a command that will do the following, in order:
Measure the width of an input word.
Compare this value to an existing value.
If the input word's width is greater, then take on ...
1
vote
1
answer
34
views
LaTeX reserving space for undrawn coordinates
I'm trying to write a function to ease the drawing of figures. I called this function \drawcurve as is shown below. It's purpose is to create a curve between 2 lines indicated by coordinates in it's ...
0
votes
1
answer
88
views
Page Background for Certain Pages Only
Consider the code:
\documentclass{article}
\usepackage{background}
\usetikzlibrary{calc}
\usepackage{lipsum}
\backgroundsetup{
color=black,
scale=1,
opacity=1,
angle=0,
contents={\tikz\draw[line ...
3
votes
2
answers
141
views
round number to nearest tenth using calc
I'm trying to use the below code to get 0,1,2,...,5 but I'm getting 0.59999,0.79999,0.9999. How is it possible to fix it
\foreach \i [] in {0,0.2,...,1}{
\draw (0,{5*\i}) --++(-0.2,0) node[left]{$\...
1
vote
1
answer
84
views
Calc \widthof error
I'm trying to use the \widthof command (calc package) inside the \ifdimcomp command (etoolbox package), but I keep getting an error "Missing number, treated as zero" which confuses me. I'm ...
2
votes
0
answers
68
views
How to Produce a Rectangular Radial Glow
Consider the code
\documentclass[a5paper,12pt,onecolumn,openany,final]{book}
\usepackage[hmargin=0.7in,vmargin=0.75in]{geometry}
\usepackage{tikz}
\usepackage{calc}
\usetikzlibrary{fadings}
\...
3
votes
1
answer
55
views
Tikz: use coordinates returned from macro
How to use a coordinate returned from a macro, for instance, with shift? See the following MWE. I tried changing where the involved delimiters are defined (inside or outside the macro), but I always ...
0
votes
1
answer
51
views
Spacing by a calculated value with a counter
I want to create an oblique table of content, my strategy has been so far to do the following:
\newcounter{agendacount}
\setcounter{agendacount}{0}
\setbeamertemplate{section in toc}{%
\hspace{-0....
1
vote
1
answer
67
views
Measure the horizontal distance between two nodes and apply to relative placement between two other nodes
I would like to measure the horizontal distance between two nodes A and B, and then place another node Y the same horizontal distance from X, but aligned vertically with v0.
What's the syntax for that?...
-1
votes
4
answers
323
views
How to \read inside a command and return the result?
As a followup of How to use file content as a numeric value for a length?, I'm trying to do this (I really need to read the data.txt file inside this new command and use the value later, when the ...
0
votes
1
answer
45
views
How to use decimal computations inside parentheses to compute the height of an image?
I have the following LaTeX file which does not compile:
\documentclass{report}
\usepackage{calc}
\usepackage{graphicx}
\newcommand\AFiveHeight{210mm}
\newcommand\BodyToLayoutRatio{0.7}
\newcommand\...
3
votes
2
answers
150
views
Coloring slices of a hypermatrix
I was able to use tikz to make a 2 by 2 by 2 hypermatrix using the following latex code:
\documentclass{article}
\usepackage{tikz-cd}
\usetikzlibrary{calc}
\usetikzlibrary{arrows}
\begin{...
3
votes
8
answers
899
views
How do I print an increasing value with iteration in LaTeX?
For example, I want to print all values x + 1 with n repetition
In Python it would be:
def arithmetic_add_1_(n,x):
for k in range(n):
print(x)
x = x+1
print(x)
with n -> repetitions
...
2
votes
1
answer
198
views
How to draw \hrule based on text width?
I have a \divider command where it draws a thick hrule and a thin hrule to achieve the style I want:
\newcommand{\divider}[1]{%
\vskip-2pt %
{%
\color{black}%
\hrule%
}%
...
4
votes
2
answers
495
views
How can I calculate width using an expression (like \textwidth - \widthof{dummy text})?
Take a table for example. We have one column with some arbitrary length short text, and the other column has large descriptions.
To save the reader time:
\documentclass{article}
\usepackage{lipsum}
\...
2
votes
1
answer
79
views
Negating coordinates
This actually seems like an easy thing to do but I have not found any solution:
I would like to negate/invert predefined coordinates as simple and with few characters as possible. I.e. using (A) as (0,...
0
votes
1
answer
294
views
Multiply constant to \widthof
I'm trying to compress some text using \resizebox.
When I use an absolute value, it works fine
\resizebox{2em}{\height}{AAAAA}
when I use a partial of e.g. \textwidth it also works fine
\resizebox{0....
1
vote
2
answers
57
views
How can you align text in a tabular in the top left corner with listing
I am creating a pseudo latex interface of a console GUI. I do not want to use screenshots of the GUI because I need the text to be able to go to the next page.
What I have right now is this:
\...
4
votes
1
answer
302
views
An environment of tcolorbox to draw vertical lines configurable in numbers and in color?
I was inspired by the code of Ignasi in the following link:
Mark (highlight) a paragraph (\item{…}) with a squiggly line across several pages
I modified it to do the following command:
which draws #1 ...
1
vote
0
answers
79
views
setting column width in tabular* with the calc package
I have a problem setting the column with using the calc package, which should be quite straightforward, but I cannot figure it out.
\documentclass{article}
\usepackage{array}
\usepackage{calc}
\...
0
votes
1
answer
441
views
Package calc error`\let ' invalid at this point, probably wrong unit of measure
I'll attach a MWE which replicates the problem
\documentclass[a4paper,11pt,oneside,notitlepage,reqno]{book}
\usepackage{minted}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[...
3
votes
2
answers
242
views
LaTeX throws error on \heightof
I'm trying use \heightof in my document but XeLaTeX throws an error. Both minimal code end errors are below. Ubuntu 20.04 with latest updates
\documentclass[14pt,a4paper]{extarticle}
\usepackage{calc}
...
2
votes
3
answers
166
views
Is there more compact way of simple point calculations?
I have this code:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (2,2);
\draw[...
2
votes
2
answers
48
views
Replacing length registers in expressions
I have some understanding on how to use length registers for calculations. However, I always end up requiring way too many length registers for tasks which could probably be solved better by ...
3
votes
2
answers
1k
views
How to use "calc" library to sum coordinates?
Why does the following code draw an inclined line? I thought the sum ($(1,6) + (2,0)$) would return a point (3,6).
\documentclass[dvipsnames]{article}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\...
1
vote
1
answer
115
views
Specify the precision in mathparse calculus
I have defined the function f(x) = (sqrt(x)-1)/(x-1) and I need to calculate several values for f(x).
I have developed the following code, but, I cannot to specify the precision for f(x), for example, ...
1
vote
1
answer
222
views
patching \setcounter and \addotocounter not working well with calc
for some very specific needs of reledac, I need to get the value of the page counter each time it is changed, either via settocounter, either with addotcounter.
So I did something like this (it is a ...
2
votes
0
answers
125
views
Does the \setlength have any feature not found in geometry package ؟ [closed]
Do we need to use \setlength if we use the geometry package? Does the \setlength have any feature not found in geometry package?
4
votes
2
answers
279
views
Why can't I multiply size by integer in calc?
This is what I'm doing:
\documentclass{article}
\usepackage{calc}
\newlength{\foo}
\newcommand{\zzz}{5}
\setlength{\foo}{\zzz * 2in}
\usepackage[paperwidth=\foo,paperheight=\foo]{geometry}
\begin{...
1
vote
1
answer
79
views
In LaTeX, can I access the contents of a hyperref TextField and display them below, marked up in math mode?
It's fairly easy to set up a fillable field. How can I access the contents of that field and display them, marked up using math mode?
\documentclass[a4paper,11pt]{article}
\usepackage{hyperref}
\...
0
votes
0
answers
527
views
Calc Style is Missing from TexLive
I am quite new to the tex space. I recently installed Latex in conjunction to texlive (easy editor). I need to write a paper in astronomy and astrophysics but when I use the required template it says ...
0
votes
1
answer
397
views
Rules of column width in tabular
I would like to put rules in a tabular to "strike out" a number of consecutive cells within one row. I want these rules to automatically adjust to column width.
For example, the width of ...
2
votes
1
answer
49
views
gcd in spreadtab error
why wont my code work? I get up to 22 errow massages
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{dcolumn}
\usepackage{spreadtab}
\usepackage{siunitx}
\usepackage{mathtools}
\...
2
votes
1
answer
54
views
a bug with calc and ehhline together
Days before, I was dealing with the problem of drawing horizontal lines between colored multirow cell with \hhline. I tried two method and took the second at last. But I found there is a bug in the ...
1
vote
1
answer
130
views
ssconvert convert to table, ratio calculate error : Missing number, treated as zero
ssconvert convert to table,but ratio calculate error.
I searched around and found no solution. Is there a problem with ssconvert's table conversion?
\documentclass{article}
\def\inputGnumericTable{} ...
6
votes
3
answers
670
views
Change cone width
I am trying to draw some simple cones as depicted below
Using my own code this is what I have so far
How can I make the base of the green cone narrower so it fits within the gray one
Why are only ...
0
votes
1
answer
251
views
LaTeX Math operations
I am trying to add two values and then multiply them by a number but in order to do it in that order I have to use parentheses. The problem is that when I add parentheses I get a compilation error.
...
3
votes
1
answer
344
views
Adjusting minipage's width to avoid line breaks
For foo and baz, widthof return sensible/nonsensible values. When the width of the minipage wrapped around foo and baz is set to these numbers, neither has the desired width, that is, the width of the ...
2
votes
1
answer
57
views
"Hidden text" inflates `widthof`
French letters call for a heading stating place and date, which I put in \letterlieudate, which I put in a minipage. Requirement: that the minipage's width be just big enough so that \letterlieudate ...
2
votes
1
answer
132
views
Can tikz projections be computed in three dimensions?
According to the pgf manual, the syntax
<coordinate>!<projection coordinate!<angle>:<second coordinate>
can be used to project <projection coordinate> orthogonally onto ...
2
votes
1
answer
180
views
Tikz: Calculations with coordinates
Inspired by the question How to draw a line passing through a point and parallel to another? I'm trying to do some arithmetic with coordinates. The code below does not work, but I hope that with a ...
5
votes
1
answer
232
views
Climate flow chart
I am trying to draw the following "flowchart"
After some fiddling I was able to come up with the following solution
What I am struggling with mainly boils down to two things
How can I align the ...
1
vote
0
answers
63
views
calculate the title height and if the title height is above some number then add some space
calculate the title height and if the title height is above some number then add some space.
when I use the code get the title, but when I use code like this \settoheight{\heightoftitle}{\vbox{\...
7
votes
2
answers
574
views
Relationship between strut and baselineskip
Here, it is said that a strut is defined as:
\rule[-.3\baselineskip]{0pt}{\baselineskip}
However, if I do:
\newlength{\strutheight}
\settoheight{\strutheight}{\strut}\printlength{\strutheight}
\...
1
vote
0
answers
47
views
Set an option to a custom environment to change width of a setheight
I'm tuning the code @CarLaTeX proposed in this topic to separate teacher version and student version.
The goal is when the boolean is true (student version), a blank line takes the place of the stuff....
2
votes
2
answers
435
views
Basic TikZ "Missing number" error when using `asin` to calculate the end angle of arc
I am new to plotting in TikZ and has come across the "Missing number error" in the following example on the line marked by %(**),
\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{calc,shapes....
1
vote
1
answer
87
views
Using zref return value as input for counter
I am trying to create a new counter, which is counting the page numbers to store them and reuse them later. I always remove the 3 pages, which are not numbered at the beginning of the document and I ...