Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [calc]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3 votes
1 answer
46 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 ...
user avatar
  • 155
0 votes
1 answer
41 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....
user avatar
  • 101
1 vote
1 answer
36 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?...
user avatar
  • 1,894
0 votes
1 answer
57 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 ...
user avatar
  • 10.1k
0 votes
1 answer
41 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\...
user avatar
  • 125
3 votes
2 answers
119 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{...
user avatar
  • 239
3 votes
8 answers
722 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 ...
user avatar
  • 49
2 votes
1 answer
83 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% }% ...
user avatar
4 votes
2 answers
233 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} \...
user avatar
2 votes
1 answer
51 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,...
user avatar
  • 387
0 votes
1 answer
72 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....
user avatar
  • 140
1 vote
2 answers
43 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: \...
user avatar
4 votes
1 answer
114 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 ...
user avatar
1 vote
0 answers
39 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} \...
user avatar
  • 155
0 votes
1 answer
196 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[...
user avatar
2 votes
2 answers
157 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} ...
user avatar
2 votes
3 answers
147 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[...
user avatar
  • 345
2 votes
2 answers
39 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 ...
user avatar
2 votes
2 answers
449 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} \...
user avatar
  • 345
1 vote
1 answer
51 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, ...
user avatar
1 vote
1 answer
124 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 ...
user avatar
  • 10.7k
2 votes
0 answers
89 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?
user avatar
4 votes
2 answers
201 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{...
user avatar
  • 10.1k
1 vote
1 answer
59 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} \...
user avatar
  • 11
0 votes
0 answers
448 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 ...
user avatar
  • 101
0 votes
1 answer
169 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 ...
user avatar
2 votes
1 answer
38 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} \...
user avatar
  • 359
2 votes
1 answer
48 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 ...
user avatar
  • 4,336
1 vote
1 answer
71 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{} ...
user avatar
6 votes
3 answers
644 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 ...
user avatar
0 votes
1 answer
151 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. ...
user avatar
3 votes
1 answer
197 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 ...
user avatar
  • 1,868
2 votes
1 answer
55 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 ...
user avatar
  • 1,868
2 votes
1 answer
118 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 ...
user avatar
2 votes
1 answer
84 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 ...
user avatar
  • 1,285
5 votes
1 answer
206 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 ...
user avatar
1 vote
0 answers
59 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{\...
user avatar
  • 299
6 votes
2 answers
404 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} \...
user avatar
  • 4,263
1 vote
0 answers
31 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....
user avatar
  • 991
2 votes
2 answers
228 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....
user avatar
1 vote
1 answer
72 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 ...
user avatar
  • 283
4 votes
2 answers
703 views

How to evaluate an expression and use the result in newcommand?

I am trying to declare a newcommand \newcommand{\seq}[3]{#1_#2, #1_{#2 + 1} \cdots ,#1_#3} What I want is basically to print the sequence $v_0, v_1, \cdots, v_N$ by calling \seq{v}{0}{N} but it is ...
user avatar
  • 215
2 votes
1 answer
508 views

Riemann Sum approaches Area under Curve

I am trying to write a program where I can change the number of subintervals, n( using \def\n\some number), and the output show that specific number of rectangles in the Riemann Sum. An animation ...
user avatar
  • 2,431
10 votes
2 answers
1k views

Call for node distance as a variable in TikZ

Is it possible to use the node distance as a variable while expressing coordinates of new nodes with Calc and Positioning libraries? What I want to have is everything within a single piece of code for ...
user avatar
  • 99
1 vote
0 answers
117 views

Problems with enumitem and calc

Below is a MWE with the calc and enumitem packages: \documentclass{report} \usepackage{enumitem} \usepackage{calc} \begin{document} \chapter{Title} \section{Section} \begin{enumerate}[labelindent=...
user avatar
3 votes
1 answer
328 views

Problem with \newdimen and \widthof

I have a problem with the following code under TexLive 2018: \documentclass{report} \usepackage{calc} \usepackage[inline]{enumitem} \usepackage{parskip} \newdimen\lblwidth\lblwidth=\widthof{8.88.\ }...
user avatar
2 votes
1 answer
201 views

calc and xassoccnt incompatible?

I'm getting LaTeX warning: Package xassoccnt Warning: Warning: Package "calc" is loaded -- this is not (xassoccnt) recommended for xassoccnt with calc 2017/05/25 v4.3 xassoccnt ...
user avatar
  • 6,382
8 votes
1 answer
201 views

Why conflict between mathtools and Gonzalo's solution for auto-adjusting description environment?

Gonzalo Medina provided a nifty solution to "Automatically set description list labelwidth based on widest label?." (The goal was to define a description environment where the item text is ...
user avatar
5 votes
2 answers
822 views

How to define a variable as another variable divided by two?

I would like to define a variable \j in a loop \foreach \i in { 2, 4, 6} and use \j to labels of the nodes. Here is my code: \documentclass{standalone} \usepackage{balance,complexity,pgfplots,tikz,...
user avatar
  • 1,372
5 votes
1 answer
322 views

Is there an incompatibility between the packages calc and siunitx? (\GenericError [...])

The following code does not compile: \documentclass[11pt]{article} \usepackage{calc} \usepackage{siunitx} \begin{document} \begin{tabular}{p{.5cm}p{\widthof{\textbf{AAAAAAAAA}}}l} &\textbf{...
user avatar
  • 179