## 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:

STR1 = "\alpha+\beta"STR2 = "\gamma bla bla bla"STR3 = "Hello this is a complex equation!"STR4 = "Please help me guys!!!!" \begin{tabular}{|c|c|}	\hline STR1	&  STR2\\ 	\hline STR3	&  STR4\\ 	\hline \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: 8665
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:
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: 8665
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:
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