7

I'm a LaTeX newbie, but I've been doing my homework, and now I have a question that I can't seem to find the answer to. I create the definition of an equation, let's just say it's this one:

The potential is characterized by a length $\sigma$ and an energy $\epsilon$.

In reality, this equation is more complex, which is why I wanted to try a shortcut. If my equation were this simplistic, I wouldn't try my substitution technique. I use the \renewcommand to save me some time:

\renewcommand{\sigma}{1}

And this works fabulously and will replace all instances of sigma with 1. Unfortunately though, since \sigma has a global scope, I need to reset it. I tried a couple different ways:
Attempt 1: -deadlock due to circular reference?

\newcommand{\holdsigma}{\sigma}
\renewcommand{\sigma}{1}
The potential is characterized by a length $\sigma$ and an energy $\epsilon$.
\renewcommand{\sigma}{\holdsigma}

I would think to reset the command, it should look something like this:

\renewcommand{\sigma}{\greek{\sigma}}

but that obviously hasn't worked out for me.

Any idea about how the greek letters are originally defined in the language?

TopherGopher
  • 655
  • 11
  • 21
  • 1
    Don't forget about http://tex.stackexchange.com/ – Gabe May 01 '11 at 02:09
  • 1
    This seems like a really bad idea. You'll have to flip the definition of `\sigma` back and forth any time you need to use it. You can't edit the equation(s) and use a `\mysigma` or something? – drysdam May 01 '11 at 02:18
  • I thought about that, and that's probably what I'll end up doing, but for future reference, I wanted to know if it was possible to flip back and forth. – TopherGopher May 01 '11 at 02:33
  • I'm sorry Gabe, I didn't realize that there was a teX site. Should I repost over there? – TopherGopher May 01 '11 at 02:35
  • @chrisbster: No, the [consensus](http://meta.stackexchange.com/questions/12918/can-we-have-a-ruling-on-latex-on-stack-overflow) was that LaTeX questions are often programming-related (like here, which is about how to find the definition of a command in the language and redefine it) — more so than many CSS questions anyway! — so it's fine to ask them here. It's just that you're more likely to get faster and better answers on the dedicated tex.stackexchange community. – ShreevatsaR May 01 '11 at 05:22
  • Do not ask "how do I use X to do Y in Z?" Ask "how do I do Y in Z?" – Svante May 01 '11 at 14:55
  • @Svante: Sometimes it's nice to know, specifically, whether one was on the right lines with `X`; whether one had successfully come up with a reasonable solution on his/her own. – Lightness Races in Orbit Jul 09 '11 at 22:10

2 Answers2

12

I have to admit that I don't understand why you want to do what you're asking, but this should work:

\documentclass{article}
\begin{document}

Before redefinition, \verb|\sigma| looks like $\sigma$.

% Copy the current definition of \sigma to \oldsigma
\let\oldsigma\sigma

% Redefine \sigma to be '1'
\renewcommand{\sigma}{1}

After redefinition, \verb|\sigma| looks like $\sigma$.

You can still use \verb|\oldsigma| if you want to use the original definition $\oldsigma$.

% Restore the original definition of \sigma
\let\sigma\oldsigma

Now \verb|\sigma| is back to its normal appearance $\sigma$.

\end{document}
godbyk
  • 8,359
  • 1
  • 31
  • 26
3

To find out how \sigma or any other command is originally defined, you can use \show\sigma. (The answer is that \sigma is defined as \mathchar"11B.) You can type this either in your document itself — compilation will pause and you can type Enter after reading the reply — or you can type this in TeX/LaTeX's interactive mode.

Example with a document:

\documentclass{article}
\begin{document}
What is $\sigma$?          % Prints "What is σ" in the DVI/PS/PDF.
\show\sigma                % Prints "> \sigma=\mathchar"11B." in the compilation.
Now that we know, let us redefine it.
\renewcommand{\sigma}{1}
Now it is: $\sigma$.       % Prints "Now it is: 1." in the DVI/PS/PDF.
OK, let's go back.
\renewcommand{\sigma}{\mathchar"11B}
We again have: $\sigma$.   %Prints "We again have: σ." in the DVI/PS/PDF.
\end{document}

Or else at the command prompt, type latex, then type \relax, then type \show\sigma, read what it says, then type x to exit.

ShreevatsaR
  • 38,402
  • 17
  • 102
  • 126