## LaTeX forum ⇒ Math & Science ⇒ [SOLVED] use string variables Topic is solved

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
BastienBastien
Posts: 40
Joined: Mon Aug 20, 2012 2:27 pm

### [SOLVED] use string variables

Hello LaTeX users,
Do you know whether it is possible to use "string variables"
to simplify some LaTeX code. For instance, one could write
something that looks like:

1. STR1 = "\alpha+\beta"
2. STR2 = "\gamma bla bla bla"
3. STR3 = "Hello this is a complex equation!"
5.
6. \begin{tabular}{|c|c|}
7. \hline
8. STR1 & STR2\\
9. \hline
10. STR3 & STR4\\
11. \hline
12. \end{tabular}

So that the big tabular is easier to modify, read.

Thanks,
Regards,
Bastien
Last edited by BastienBastien on Mon Dec 25, 2017 9:52 pm, edited 1 time in total.

Tags:

Stefan Kottwitz
Posts: 9568
Joined: Mon Mar 10, 2008 9:44 pm
Hi Bastien!

That is a fundamental property of LaTeX: string macros. I'm sure you saw it already:

\newcommand{\mystr}{hello}

Then use \mystr in the text. You can have many such macros, and you can build macros of macros. But names can only contain letters, uppercase and lowercase, no numbers.

Stefan

BastienBastien
Posts: 40
Joined: Mon Aug 20, 2012 2:27 pm
Hi Stefan,

Yep for sure and I even use it a little bit.
But I though may be there is something more suitable to such usage.
Ok thanks I'll use this command.

Regards,
Bastien

Stefan Kottwitz
Posts: 9568
Joined: Mon Mar 10, 2008 9:44 pm
Yes, it looks different to a simple Str="...", as it's classic LaTeX syntax. But it serves exactly the purpose, looks the same in the text except the backslash.

Stefan