7

私はLaTeXの初心者ですが、宿題をしているので、答えが見つからないような質問があります。方程式の定義を作成します。これだとしましょう。

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

実際には、この方程式はもっと複雑なので、ショートカットを試してみたかったのです。私の方程式がこれほど単純なものである場合、私は自分の置換手法を試しません。\ renewコマンドを使用して、時間を節約します。

\renewcommand{\sigma}{1}

そして、これは見事に機能し、sigmaのすべてのインスタンスを1に置き換えます。ただし、\ 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}}

しかし、それは明らかに私にとってはうまくいきませんでした。

ギリシャ文字が元々その言語でどのように定義されているかについて何か考えはありますか?

4

2 に答える 2

12

私はあなたがあなたが求めていることをなぜやりたいのか理解していないことを認めなければなりませんが、これはうまくいくはずです:

\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}
于 2011-05-02T02:26:59.470 に答える
3

他のコマンドが最初にどのように定義されているかを調べる\sigmaには、を使用できます\show\sigma。(答えは次の\sigmaように定義されてい\mathchar"11Bます。)これはドキュメント自体に入力できます—コンパイルは一時停止し、返信を読んだ後にEnterと入力できます—またはTeX/LaTeXのインタラクティブモードで入力できます。

ドキュメントの例:

\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}

または、コマンドプロンプトで、と入力しlatex、次に入力\relaxし、次に入力し、その\show\sigma内容を読み、入力xして終了します。

于 2011-05-01T05:19:27.047 に答える