Questions tagged [variable]

212 questions
5
votes
5 answers

How to accumulate content into a variable and only then print?

This is what I'm trying to achieve: \documentclass{article} \begin{document} \add{One} \add{Two} \add{Three} \print % Only here "One Two Three" will be rendered \end{document} How can this be done?
yegor256
  • 12,021
5
votes
1 answer

Can you create concatenate variable names in LaTex?

I would like to create variables to hold strings like f(x)=3x+1 to be inputted into an exam questions. I can create variables like \funA, \funB, … et cetera. The problem is how do I reference them using A, B, … et…
5
votes
2 answers

generate 100 pages document with consecutive numbers

I need to generate a 100 pages document with only 1 number per page starting from 1 till 100. Any idea?
Sortee
  • 51
4
votes
2 answers

Assign a static value to a variable

I'm using the lgc package to generate random numbers. \usepackage[first=-100, last=100]{lcg} Assume I want to write the following equation $$ a x^2 + b =0$$ where $a,b$ % are random integers ranged in $[-100,100]$ the "+" sign should be "+" if…
moon
  • 41
  • 2
3
votes
2 answers

Filename from a variable (in pdfpages) - possible?

I am trying to merge two PDFs into one, alternating the pages. Unfortunately, there is no option in pdfpages that would handle this, so I am using \includepdfmerge and specify the pages to add…
Thorsten
  • 461
3
votes
3 answers

Indexing variables

Is it possible to create variables that can be defined using integers. I would create an example to work with but I have no idea how to start. Hopefully the snippet I have included makes sense. % creates variables wk[1], wk[2], ... , wk[10] \foreach…
3
votes
2 answers

Define variable without \newcommand

I'm writing an invoice class and I want to keep the actual tex file as clean as possible, so that the code does not scare off the non-techies. My ultimative goal would be to define a variable in the invoice.cls file and later set a value to it by a…
Sam
  • 2,958
2
votes
2 answers

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): \showthe\parskip have been suggested to me. Are…
Veak
  • 1
2
votes
1 answer

"Optional" package accept variable argument

\documentclass[12pt]{article} \usepackage[test]{optional} \begin{document} \def\optname{test} \optname \\ % Prints "test" \opt{\optname}{ TEST % does nothing }\\ \opt{test}{ TEST 2 % behaves as expected } \end{document} The above…
Doomsel
  • 23
1
vote
1 answer

How do I store plain text inside a variable (i.e without any formatting)

I'm trying to store text in a variable like \def\course{Statistics} but I want the text to be relaxed everywhere I execute the command. When I input \def\course{\relax Statistics}, the text is relaxed on the first page however after that it stops…
1
vote
1 answer

Formula in a variable that can be referenced later

Is there a way to put a formula in a variable (as in like a programming language variable) so that it can be referred to and rendered later? I was able to do this in Mathematica, but I'm moving away from Mathematica because I don't want to pay for…
1
vote
1 answer

How to save text in variable and print it afterwards?

I would like to create a command that: when an argument is given, it saves it "somewhere", and when no argument is given, it prints all saved arguments. Something like this: \example{text1} \example{text2} \example{text3} (not…
kuonb
  • 111
1
vote
2 answers

sum of two variables

how can I make the sum of 2 variables in cm? Example: \y+ \n \x + \m Thank in advance Minimal…
latexforti
  • 2,091
1
vote
2 answers

Distance Variable in front or back pages

I want to use variable VARX of front/ back pages Example: in front pages: varx = 5cm In back pages: varx = 10cm My minimal code (Varx is always = 5cm) \documentclass{article} \usepackage{datatool,filecontents} \begin{filecontents*}{test1.csv} Acol,…
latexforti
  • 2,091
1
vote
0 answers

Define variable for color and \AbsolutePosition{x, y}

I have 10 files and each file has different distance variables and color variable in the code: \AbsolutePosition{\x_var}{\y_var}{ \begin{tikzpicture} \draw [\colour_var,fill=\colour_var] (0,0) rectangle node[text=white,text centered,rotate=270]…
latexforti
  • 2,091
1
2