我是 LaTeX 新手,但我一直在做功课,现在我有一个似乎找不到答案的问题。
我创建了一个方程的定义,让我们说它是这个:
The potential is characterized by a length $\sigma$ and an energy $\epsilon$.
实际上,这个等式更复杂,这就是我想尝试一条捷径的原因。如果我的方程式如此简单,我就不会尝试我的替代技术。
我使用\renewcommand 来节省我一些时间:
\renewcommand{\sigma}{1}
这非常有效,并将用 1 替换所有 sigma 实例。不幸的是,由于\sigma 具有全局范围,我需要重置它。
我尝试了几种不同的方法:
尝试 1:由于循环引用导致死锁?
\newcommand{\holdsigma}{\sigma}
\renewcommand{\sigma}{1}
The potential is characterized by a length $\sigma$ and an energy $\epsilon$.
\renewcommand{\sigma}{\holdsigma}
我想重置命令,它应该是这样的:
\renewcommand{\sigma}{\greek{\sigma}}
但这显然对我不起作用。
知道希腊字母最初是如何在语言中定义的吗?
最佳答案
我不得不承认,我不明白你为什么想做你所要求的,但这应该有效:
\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}
关于latex - 如何使用\renewcommand 取回我的希腊字母?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5845887/