
我想標記一個方程
\[ 1 + 2 + \cdots + i = \frac{i(i+1)}{2} \eqname{Inequality(i)} \label{ineq} \]
涉及變數「i」作為 (i) 的函數,因此預期輸出如下
[上式的 LaTeX 渲染] (2.4)(i)
(這實際上意味著有“i”個這樣的方程式)。 (2.4) 可能參考第 2 節的方程式 4。
由於方程式 (2.4)(n+1) 由方程式 (2.4)(n) 得出,因此使用歸納法...
(編輯:改進措辭以澄清評論中的問題。)
答案1
讓我們看看我是否猜對了你想要得到的東西:
此輸出由以下程式碼產生:
% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.
\usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.
\usepackage{amsmath}
\numberwithin{equation}{section}
\newcommand*{\myTagFormat}[2]{(\ref{#1})($#2$)}
\begin{document}
\section{First}
Just to include a couple of equations:
\begin{align}
1 &= 1 \label{eq:one} \\
1+2 &= 3 \label{eq:two}
\end{align}
Until now, we have equations \eqref{eq:one} and~\eqref{eq:two}.
\section{Second}
Still another equation of the same form:
\begin{equation}
1+2+3 = 6 \label{eq:three}
\end{equation}
Generalizing equations \eqref{eq:one}, \eqref{eq:two}, and~\eqref{eq:three}, we
claim that
% Little trick:
\refstepcounter{equation}\label{eq:base}% <-- Note!
\begin{equation}
1+2+\dots+n = \frac{n(n+1)}{2}
\tag*{\myTagFormat{eq:base}{n}}\label{eq:base-n}
\end{equation}
Now you can either:
\begin{itemize}
\item
reference equation~\ref{eq:base-n} directly (note that you must use
\verb|\ref| instead of \verb|\eqref|, here), or
\item
say that equation~\myTagFormat{eq:base}{i+1} follows from
equation~\myTagFormat{eq:base}{i} by adding $i+1$ on both sides of the
latter.
\end{itemize}
One more equation to check that we haven't spoiled the numbering:
\begin{equation}
x=y
\end{equation}
\end{document}
答案2
使用mathtools
package 命令\newtagform
,您可以非常詳細地自訂方程式編號。該指令的一般語法為:
\newtagform{label}[tag format]{left}{right}
這label
只是標記方法的唯一 ID,可以使用命令檢索\usetagform{label}
,left
並且right
應該寫入標記的左側和右側(通常是括號)。這tag format
是您想要的標記的詳細資訊。在您的特定情況下,您可以使用以下語法:
[\renewcommand{\theequation}{(\arabic{chapter}.\arabic{section})(\roman{equation})}]
設定新的編號格式後,您還必須變更引用方程式時方程式的顯示方式。對於您想要的樣式,程式碼應該是:
\renewcommand{\theequation}{(\arabic{chapter}.\arabic{section})(\roman{equation})}
以下是此自訂編號如何運作的範例:
\documentclass[]{report}
\usepackage{amsmath}
\usepackage{amssymb, amsfonts}
\usepackage{gensymb}
\usepackage{mathtools}
\newtagform{Alph}[\renewcommand{\theequation}{(\arabic{chapter}.\arabic{section})(\roman{equation})}]{}{}
\usetagform{Alph}
\renewcommand{\theequation}{(\arabic{chapter}.\arabic{section})(\roman{equation})}
\begin{document}
\chapter{First Chapter}
\section{First Section}
\label{sec:one}
\begin{equation}
I = I_{ ph } -
\overbrace{
I_{ rs }
\biggl[
exp \biggl(
\frac{V + I R_{s}}{a \thinspace V_{t}}
\biggl) - 1
\biggl]
% overbrace title
}^{ I_{d} }
-
\overbrace{
\frac{V + I R_{s}}{R_{p}}
% overbrace title
}^{I_{p}}
%
\label{eq:I_PV_m}
\end{equation}
\begin{equation}
\label{eq:R_p}
%
R_{p} = R_{p,ref} \biggl( \frac{G_{ref}}{G_{op}} \biggl) \biggl( \frac{T_{op}}{T_{ref}} \biggl)^{\delta_{p}}
\end{equation}
\begin{equation}
PMARE = \underset{i}{max}
\biggl| \frac{x_{i}-y_{i}}{y_{i}} \biggl| \times 100\%
\quad i = 1, 2, \cdots , n
%
\label{eq:PMPARE}
\end{equation}
A test for referencing Eqs. \ref{eq:I_PV_m}, \ref{eq:R_p}, and \ref{eq:PMPARE} which belong to Section \ref{sec:one}.
\section{Second Section}
\label{sec:two}
\begin{equation}
\label{eq:R_{s}}
%
R_{s} = R_{s,ref} \biggl( \frac{T_{op}}{T_{ref}} \biggl)^{\delta_{s}}
\end{equation}
\begin{align}
I_{ph} &= I_{sc} \frac{R_{s} + R_{p}}{R_{p}} \notag
\\
&= I_{sc,ref} \bigg[ 1 + \frac{\alpha}{100} (T_{op}-T_{ref}) \biggl]
\frac{G_{op}}{G_{ref}} \frac{R_{s} + R_{p}}{R_{p}}
%
\label{eq:I_ph}
\end{align}
A test for referencing Eqs. \ref{eq:R_{s}} and \ref{eq:I_ph}which belong to Section \ref{sec:two}.
\end{document}
其他類型的編號選項包括\Roman
(大寫羅馬字母)\alph
和\Alph
。祝你好運
答案3
我在第一次閱讀時並沒有真正理解這個問題,我以為你想要類似的東西這。
但這並不完全是你想要的,因為我的答案不能給出像 (n+1) 這樣的結果......但如果我們稍微改變一下,我們可以得到這個:
\makeatletter
\newcommand*\ifcounter[1]{%
\ifcsname c@#1\endcsname%
\expandafter\@firstoftwo%
\else%
\expandafter\@secondoftwo%
\fi%
}%
\makeatother
\makeatletter
\newcommand\EqFamCustomTag[2]{%
\ifcounter{#1}{%
\expandafter\addtocounter{#1}{1}%
\xdef\temp{\csname #1 Eq\endcsname \space(#2)}%
\global\expandafter\let\csname #1\arabic{#1}\endcsname\temp%
\tag{\temp}%
}{%
\global\expandafter\newcounter{#1}%
\expandafter\addtocounter{#1}{1}%
\xdef\temp{\theequation\space(#2)}%
\xdef\eqonfamily{\theequation}%
\global\expandafter\let\csname #1 Eq\endcsname\eqonfamily%
\global\expandafter\let\csname #1\arabic{#1}\endcsname\temp%
\tag{\temp}%
\expandafter\addtocounter{equation}{1}
}%
}%
\makeatother
可以這樣使用:
\begin{equation}
\frac{x^2}{2}+\frac{3\cdot y^2}{10}=2\EqFamCustomTag{Elliptic}{n+1}
\end{equation}
並給你你想要的......(我希望)...對於你擁有的其他方程中的自動編號,你可以使用我提到的問題答案之一(這個問題也開始了.. ....)