Questions tagged [variable]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
52 views

Displaying variable which is defined after the variable is used in text

I have a situation where I need to access a variable which is defined after it is used in the text. An example of what I'm trying to achieve is below, essentially the definition of variable happens ...
John Tracey's user avatar
0 votes
0 answers
26 views

How to compose "variables" in the animate package within the multiframe command?

I am using the \multiframe command to create a loop \multiframe{54}{i=1+2 }, starts the loop at i = 1 , increases i by increment of 2, and 54 times Within the loop, you can use \i to refer to the ...
stackoverflower's user avatar
0 votes
1 answer
108 views

Validity of \def in tikz

The following code does not resolve the defines inside tikzpicture and thus does not print the labels. \documentclass[tikz]{article} \usepackage{keycommand} \usepackage{ifthen} \usepackage{tikz} \...
RootRaven's user avatar
  • 249
3 votes
2 answers
97 views

LaTeX macro for summing numbers

I have a very simple LaTeX problem which confuses me. I want to write a macro which creates a running total of given numbers. The answer by Ulrike Fischer here is almost exactly what I want - simple ...
SvenForkbeard's user avatar
0 votes
0 answers
34 views

Automatically calculate years of experience from provided start/end dates

I'm very very new to LaTeX and not even sure if this is possible. \resumeSubheading {Undergraduate Research Assistant} {6 Years \& 3 Months} % 1 <---------------...
Aagam Sheth's user avatar
7 votes
1 answer
102 views

Passing integer expl3 variables to a Lua function (via \lua_new:e)?

Given the following MWE: \documentclass{minimal} \ExplSyntaxOn \int_new:N\g_test_myint_int \int_set:Nn\g_test_myint_int{2} \cs_set:Npn\__test_dostuff: { \lua_now:e{tex.sprint(1)} % Works just ...
Chris W's user avatar
  • 73
2 votes
2 answers
241 views

Displaying values of latex variables

What would be the procedure to see the value of a latex variable such as \baselinestretch and \parskip. Macros, such as \baselinestretch): \show\baselinestretch and for a dimension such as \parskip): \...
Veak's user avatar
  • 1
0 votes
2 answers
96 views

Check if parameter in command is declared/empty in LuaLaTeX

I'm trying to check if a parameter is declared/empty using lua. So far I wrote the following MWE: \documentclass{standalone} \def\var#1{\def\@var{#1}} %\var{Hello world} \begin{document} \@var --...
Levy's user avatar
  • 1,135
3 votes
1 answer
70 views

Define variable in LaTeX with value contain mathematical operator

\documentclass[a4paper,oneside,12pt]{book} \begin{document} \def\s{(1/(2+sqrt(2)))} \s \end{document} I want make a variable \s with the value 1/(2+sqrt(2)). LaTeX cannot automatically ...
Ongky Denny Wijaya's user avatar
0 votes
1 answer
19 views

Variables set within tables and reused later in the document

I am writing a document that involves a table of information for many sections, something like: \textbf{Details:} \begin{table}[H] \begin{center} \begin{tabularx}{\linewidth}{|X|c|c|c|c|c|} ...
BugInACode's user avatar
1 vote
1 answer
55 views

How to properly set optional boolean parameter for pic in tikz?

I try to draw beam on tikz with the possibility to hide its axis. I created the following: \documentclass{article} \usepackage{tikz} \usetikzlibrary{math, shadings} \usepackage{ifthen} \tikzset{ ...
Sindzicat's user avatar
  • 113
1 vote
2 answers
35 views

How to use a variable in a thmnote

I'd like to have the "theorem name" of a theorem be populated using a variable. It isn't working as I had hoped, see below. I'm especially confused because I can successfully get the "...
macbeth's user avatar
  • 123
5 votes
1 answer
210 views

Variable naming inside l3keys

I have a question about naming variables. In expl3, the variable naming convention is the following: \<scope>_<module>_<description>_<type>. The <scope> can be l, g, or c,...
User23456234's user avatar
  • 1,611
2 votes
1 answer
64 views

Operation with counter values of two \foreach loops to reference element of array in tikz

I would like to use the \x and \y variables of the two nested \foreach loops in my tikz script to reference the elements of a list. The code looks like this : \documentclass{minimal} \usepackage{tikz} ...
lazerbeam's user avatar
2 votes
2 answers
167 views

How to use loop for creating defined number of newcommands counting authors

For my template I want to create possibility to define a number of authors and automatically create a respective number of variables/commands which save the name of any author and make it able to ...
lukeflo's user avatar
  • 1,483
2 votes
2 answers
56 views

Illegal unit, and missing number when trying to define variables

When trying to make a sequence of graphs of step functions, I wrote the following code snippet: \begin{tikzpicture} \pgfmathsetmacro{\n}{2^3}; \pgfmathsetmacro{\step}{1/\n}; \foreach \i in {0,\step,......
Addem's user avatar
  • 867
0 votes
0 answers
29 views

display a variable before assignment [duplicate]

How can I display a variable at the beginning of a document, when the variable is assigned later in the document ? I want to use \myVar{} here, but the assignment is later : \def \myVar {some text}.
dove's user avatar
  • 1
0 votes
1 answer
41 views

Comparing pgfkey variable against a string

I want to check a mutable variable against many possible values, so that a macro will behave differently based on that value. Since there are many variables, they are stored using pgfkeys. Testing ...
eduardofischermath's user avatar
0 votes
1 answer
34 views

How to place a defined variable at multiple locations

I would like to use the defined variable - \arrows[#1] - from this tikz example: https://texample.net/tikz/examples/overlapping-arrows/ % Overlapping arrows % Author: Elena Botoeva \documentclass{...
David Cross's user avatar
0 votes
1 answer
168 views

Pandoc CMD call tex template and pass variables

I'm trying to pass variables to a tex template to generate a PDF with those values via pandoc. This is my template: \documentclass[15pt]{article} \usepackage{sectsty} % Margins \topmargin=-0.45in \...
Lucas Fath's user avatar
1 vote
1 answer
49 views

Improve custom-defined variables

I am using the following code to define new custom variables, along with the existing ones, and use their values later in the document. \newcommand\subtitle[1]{\newcommand\zzsubtitle{#1}} \newcommand\...
Subhajit Paul's user avatar
0 votes
1 answer
29 views

How to avoid spacing issue when inserting def value in text?

When I define a variable: \def\company{ACME} And use it: The company \company is... I usually have the trailing space eaten by the command resulting in The company ACMEIs So I do the following: The ...
nowox's user avatar
  • 1,353
1 vote
2 answers
42 views

How to properly shorten if condition?

\documentclass{article} \title{} \author{} \date{} \begin{document} \newcommand{\mybold}[2]{\ifnum #1=1 \textbf{#2} \else{#2} \fi} \mybold{1}{This should be bold} \mybold{0}{This should NOT be bold} ...
nch7822's user avatar
  • 11
2 votes
1 answer
103 views

reusable section templates and variables

I'm looking for a way to declare a section (a chapter for instance) like that: \startchapter[title={My first interview}][author={Jane Doe}, year={2022}] … \input knuth \stopchapter \startchapter[...
Alex's user avatar
  • 55
0 votes
0 answers
80 views

Create new variable that can change along the document

Apologies for the vague title, I do not know how to word this question properly. I want to create a variable that keeps track of the date on which I finished a certain section of my course notes while ...
Lorenzo Riva's user avatar
0 votes
0 answers
45 views

Is there any way to simplify a variable expression or solve for a variable in terms of variable in Latex?

It would mean so much if someone could help me with this. I am doing some research and am using models and for my math analysis, I have to solve for C using this simplified version of my model. Is ...
Elaine Garrett's user avatar
3 votes
1 answer
245 views

LaTeX array variable

Can't seem to figure out how to create a variable containing multiple numbers. \def\numbers{{1,2,3,4,5},{6,7,8,9,10},{11,12,13,14,15},{16,17,18,19,20},{21,22,23,24,25}} \numbers[1][1] Expected ...
Swepz's user avatar
  • 33
0 votes
2 answers
114 views

Looking for an alternative to \numexpr: an intuitive interface for LaTeX numeric expressions

The xparse package makes writing commands easier and more flexible. The ifthen package does the same to conditionals. Is there a similar package for numeric expressions? Even better if it interacts ...
Evan Aad's user avatar
  • 10.9k
2 votes
2 answers
115 views

What is the difference between {} and [] parameters? [duplicate]

Most commands use {} to receive parameters. For example $\binom{6}{2}$ typesets the binomial coefficient 6 choose 2. However \sqrt receives a [] parameter as its first parameter. For example $\sqrt[3]{...
aker9397's user avatar
0 votes
1 answer
157 views

Babel: command for displaying current language

I would like to know if there is some variable in LaTeX that stores the currently used language. The context is that I have some command, lets call it \printText which prints text in the current ...
Vebjorn's user avatar
  • 1,758
1 vote
1 answer
66 views

How to remove a variable? [duplicate]

Is there a way to delete a variable so that any future references would raise an undefined control sequence error? I am dealing with a big document that has a lot of custom variables and macros with ...
gler5522's user avatar
0 votes
0 answers
47 views

Cannot save value to variable

This code defines a custom printing function that prints the numbers 1 to input. \documentclass{article} \usepackage{tikz} \begin{document} \newcommand\mynewprint[1] { \foreach[parse=true] \i in {...
landing3252's user avatar
0 votes
1 answer
121 views

Read metadata from a file

Say all homework files: hw1.tex, hw2.tex, ... use some common homework.cls. Problem is that in every hw*.tex file these variables have to be set manually. \documentclass{homework} \author{John Smith} \...
AvidSeeker's user avatar
2 votes
1 answer
25 views

Using the result that is generated later on the first page

The exam class allows one to generate a gradetable that is dynamically generated depending on the number of questions, like so \documentclass[addpoints,12pt]{exam} \begin{document} \multirowgradetable{...
M. E.'s user avatar
  • 123
5 votes
2 answers
108 views

Redefine a definition with itself, without evaluate its content

I have this MWE : \documentclass{article} \usepackage[TS1,T1]{fontenc} \usepackage[french]{babel} \newcounter{nbrefpage} \newcommand\setindex[1] {% \stepcounter{nbrefpage}% ...
Pierre Dufays's user avatar
0 votes
2 answers
52 views

Evaluate just one part of a definition, and not the other part

Let's assume we have: \def\tmpnbrefpage{sometestpagetoken} how can we define a storedpageref variable, like (in pseudo-language): "storedpageref" = \pageref{\tmpnbrefpage} where ...
Pierre Dufays's user avatar
1 vote
1 answer
40 views

Redefine def by itself without evaluate

If I have \csname var:\foo\endcsname, how can I do that : \expandafter\gdef\csname var:\foo\endcsname{\csname var:\foo\endcsname, \bar} ? I know I can do it with edef (or xdef for global), but in my ...
Pierre Dufays's user avatar
1 vote
1 answer
44 views

Fancy Header Custom Counter References

I'm trying to typeset a bible. In the header should be the current book name then the current chapter and current verse. By "current" I mean the next one in that page (or even the most ...
lmat - Reinstate Monica's user avatar
0 votes
1 answer
39 views

Printing according to conditional

I am using latex with babel and want to print the following, but within the context of a variable being set. What can I do? \begin{otherlanguage}{french} La Nuit Magique cédille Ç accent ...
Veak's user avatar
  • 1
2 votes
2 answers
146 views

Define categorized, changeable variables for use throughout a document

TL;DR How do I print categorized and subcategorized values declared in a JSON file (or in some similar type of file) inside of a LaTeX document? In my document, I am assigning a bunch of values to ...
Ben Zelnick's user avatar
1 vote
1 answer
125 views

Should I use mathrm for these variables?

I'm wondering if I read use mathrm for these variables below (relating to electrical engineering). They represents input, output or inductor voltages and ground. Reading the link I think I should use ...
hana's user avatar
  • 759
0 votes
0 answers
27 views

Error when I try define more than one variable on \newcommand [duplicate]

When I define one single newcommand the document it is fine, there is a MWE: \documentclass{article} \newcommand{\varB}{\def \@varB} \newcommand{\printvarB}{\@varB} \varB{variable B} \begin{document}...
DiegoMath's user avatar
  • 113
0 votes
1 answer
100 views

Defining numerical variables in latex preamble

In my manuscript, I need to specify the vspace command in a few places. I wonder if I can define numerical variables for this purpose in an article document class. For example, instead of typing \...
Salivan's user avatar
  • 303
2 votes
1 answer
71 views

A macro that takes in a variable that is a number, interprets it as a string, check if it has a plus sign, removes it, then stores it to the variable

I want to create a macro \foo that takes in a \newcommand variable that is a number, e.g., \bar where it's defined as \newcommand{\bar}{<number>} and interprets it as a string, then checks if ...
Farrel Ahmed's user avatar
2 votes
1 answer
170 views

Passing tex value to a lua function

I have some limitation in my understanding of how to deal with tex and lua variable. I would like to pass the result of a Tex command in order to do some computation on it. Inside the lua function, ...
Whelagen's user avatar
0 votes
2 answers
74 views

Is there a known way to build a macro that creates a dynamically sized array?

I'd like to be able to write a command that essentially takes two arguments, the number of rows and the number of columns, creates an array of the specified dimensions, and then allows for a variable ...
H. Pecoraro 's user avatar
3 votes
3 answers
966 views

Text/string variable

Is it possible to make a command or variable to store text and then later input it in the document? Example \text1{This is text from the text1 variable and it is added in here.} \text2{This is some ...
Simon Chemnitz-Thomsen's user avatar
0 votes
2 answers
158 views

How to save variable values into list [closed]

I want to save the content of a token into a list like this. \documentclass{article} \usepackage{etoolbox} \begin{document} \def\abc{1} \listgadd{\lista}{\abc} \def\abc{2} \listgadd{\...
Arysto-Krzysztof's user avatar
0 votes
1 answer
212 views

How to use dynamic numerical variables in tikzpicture?

I am currently creating technical documentation that depicts through a tikzpicture the data flow across something called the I2C bus (example-like graphic). I initially started doing this by hand with ...
Code Doggo's user avatar
0 votes
0 answers
45 views

Conventions for Distinguishing a Property when Describing Different Objects

I have several objects, in this case they are indexed sequences which are used in an algorithm written in pseudo-code and in mathematical expressions. For example, there is $V$ and $S$, and there is a ...
MVTC's user avatar
  • 101

1
2 3 4 5