Math & Science ⇒ Programming Language Variables
Programming Language Variables
a^2 + efg^2
I would like "efg" to be treated like a single variable, just like "a".
Can anyone help? Is there something I should read concerning this?
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Re: Programming Language Variables
Follow howtoTeX on twitter
- Stefan Kottwitz
- Site Admin
- Posts: 10359
- Joined: Mon Mar 10, 2008 9:44 pm
Programming Language Variables
I recommend writing a macro for your variables, so you can easily change the appearance in the complete text by modifying the macro.
Code: Select all
\documentclass{article}
\newcommand*{\var}[1]{\mathord{\mathit{#1}}}
\newcommand*{\efg}{\var{efg}}
\begin{document}
Compare $efg^2$ versus $\efg^2$
\end{document}
Stefan
Re: Programming Language Variables
The main thing, though, was to find a way to define a multi-letter variable. So thank you for the macro. That gives me an immediate solution, and an area to delve into for more ideas. Also, thanks for the hint about formatting variables differently.