방정식을 나열하기 위해 찾은 기존 예제에는 \align 환경의 방정식이 포함되어 있지 않습니다. 동일한 방정식 목록에 두 방정식 유형을 모두 포함하려면 어떻게 해야 합니까? MWE는 다음과 같습니다.
\documentclass[english]{article}
\setcounter{secnumdepth}{2}
%\setcounter{tocdepth}{1}
\usepackage{amsmath}
\usepackage{tocloft}
\usepackage{xstring}
\usepackage[unicode=true, pdfusetitle,
bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
breaklinks=false,pdfborder={0 0 0},backref=false,colorlinks=false]
{hyperref}
\makeatletter
\numberwithin{equation}{section}
% we use this for our refernces as well
\AtBeginDocument{\renewcommand{\ref}[1]{\mbox{\autoref{#1}}}}
% redefinition of \equation for convenience
\let\oldequation = \equation
\let\endoldequation = \endequation
\AtBeginDocument{\let\oldlabel = \label}% \AtBeginDocument because hyperref redefines \label
\newcommand{\mynewlabel}[1]{%
\StrBehind{#1}{eq:}[\Str]% remove "eq:" from labels
\myequations{\Str}\oldlabel{#1}}
\renewenvironment{equation}{%
\oldequation
\let\label\mynewlabel
}{\endoldequation}
% redefinition of \eqnarray for convenience
\let\oldeqnarray = \eqnarray
\let\endoldeqnarray = \endeqnarray
%\AtBeginDocument{\let\oldlabel = \label}% \AtBeginDocument because hyperref redefines \label
\newcommand{\mynewlabelarray}[1]{%
\StrBehind{#1}{eq:}[\Str]% remove "eq:" from labels
\myequations{\Str}\oldlabel{#1}}
\renewenvironment{eqnarray}{%
\oldeqnarray
\let\label\mynewlabelarray
}{\endoldeqnarray}
\newcommand{\listequationsname}{\normalsize List of Equations}
\newlistof{myequations}{equ}{\listequationsname}
\newcommand{\myequations}[1]{%
\addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}}
\setlength{\cftmyequationsnumwidth}{3em}
\makeatother
\begin{document}
%\tableofcontents
\listofmyequations
\section{Section title}
\begin{equation}
F=q[E+(v\times B)]
\label{eq:Force}
\end{equation}
\begin{equation}
\tau=F\times r
\label{eq:Torque}
\end{equation}
If the electrical force in \ref{eq:Force} is ignored,
and the remaining magnetic force is used in \ref{eq:Torque},
with the assumption that $v$ is perpendicular to $B$, we find that
\begin{equation}
\tau=qvBrsin\theta
\label{eq:Magnetic}
\end{equation}
\begin{align}
\min_{u_{i}(t),y_i, i=1...N}\!\!\!\!\!\! J(u_i(t),y_i) &:= \sum_{i=1}^N \int_0^{T} R_i(u_{i}(t),t) dt \label{eq:objective function}\\
+& \xi \int_{0}^{T} \left(\theta\frac{M - I(t)}{M}K(t) - D(t)\right)^2 dt + \sum_{i=1}^N \gamma_i y_i \notag\\
+ & \sum_{i=1}^N p_{i} \int_{T_i}^{T} u_i(t-T_i)dt \notag\\
+& h\int_{0}^T \left[\theta\frac{M - I(t)}{M}K(t) - D(t)\right]^+ dt, \notag
\end{align}
subject to
\begin{align}
K(t)& = \sum_{i=1}^N u_i(t-T_i), & \quad t\in [0,T] \label{eq:2} \\
u_i(t) &\le % \theta_i S_i(t) y_i =
\theta_i (M_i - I_i(t)) y_i, & \ \ i = 1\ldots N \quad t\in [0,T-T_i] \label{eq:ui}\\
u_i(t) & = 0, & i = 1\ldots N \quad t\in [T-T_i,T] \label{eq:uio}\\
\dot{I}_i(t)& = f_i(I_i(t)), & i = 1 \ldots N \quad t\in [0,T]& \label{eq:dotIi}\\
\dot{I}(t)& = f(I(t)), &\quad t\in [0,T] \label{eq:dotI}\\
u_i(t) & \ge 0, & i = 1 \ldots N \quad t\in [0,T]& \label{eq:const5}\\
K(t)& \ge 0, &\quad t\in [0,T]& \\
y_i &\in \{0,1\}, & i = 1 \ldots N& \label{eq:const6}
\end{align}
%where
\begin{equation}\label{eq:capacity constraint}
u^{j}_i(t) \leq Min_{p\in C^{j}_{i}} \sum_{k \in {K^{j}_{ip}}} u^{j+1}_k(t-T_k)
\end{equation}
\end{document}
답변1
매크로는 및 패키지를 \label
포함한 꽤 많은 다른 패키지에서 사용되고 재정의되므로 매크로를 수동으로 수정하는 것은 좋은 생각이 아니라고 생각합니다. 나는 방정식 목록에 나열되어야 하는 방정식에 직접 지시문을 적용할 것입니다. ( 및 환경 과 함께 사용하면 지시문이 발행 된 경우처럼 보입니다.hyperref
cleveref
\myequations
gather
align
\myequations
~ 후에줄 바꿈 지시어. 이유는 잘 모르겠습니다.)
아, 그리고eqnarray
환경을 사용하지 마십시오; 대신 사용하세요 align
.
\documentclass[english]{article}
\setcounter{secnumdepth}{2}
\usepackage{mathtools} % for \coloneqq and \mathclap macros
\usepackage{tocloft}
\usepackage[unicode=true, pdfusetitle, bookmarks=true,
bookmarksnumbered=false, bookmarksopen=false,
breaklinks=false, backref=false,
colorlinks=true,allcolors=black]
{hyperref}
\usepackage[noabbrev]{cleveref}
\counterwithin{equation}{section}
\newcommand{\listequationsname}{\normalsize List of Equations}
\newlistof{myequations}{equ}{\listequationsname}
\newcommand{\myequations}[1]{%
\addcontentsline{equ}{myequations}%
{\protect\numberline{\theequation}#1}}
\setlength{\cftmyequationsnumwidth}{2.5em}
\begin{document}
%\tableofcontents
\listofmyequations
\allowdisplaybreaks
\section{Section title}
\begin{gather}
F=q[E+(v\times B)]
\label{eq:Force} \\ \myequations{Force}
\tau=F\times r
\label{eq:Torque}
\end{gather} \myequations{Torque}
If the electrical force in \cref{eq:Force} is ignored, and
if the remaining magnetic force is used in \cref{eq:Torque},
with the assumption that $v$ is perpendicular to~$B$, we
find that
\begin{equation}
\tau=qvBr\sin\theta
\label{eq:Magnetic}
\myequations{Magnetic}
\end{equation}
\begin{equation}
\label{eq:objective function}
\myequations{Objective function}
\begin{aligned}[t]
\smash[b]{\min_{\mathclap{%
\substack{u_{i}(t),y_i,\\ i=1,\dots,N}}}}
\,J(u_i(t),y_i)
&\coloneqq \sum_{i=1}^N \int_0^{T} R_i(u_{i}(t),t)\, dt
\\
&\quad+ \xi \int_{0}^{T} \left(\theta\frac{M - I(t)}{M}K(t) - D(t)\right)^{\!2} dt
+ \sum_{i=1}^N \gamma_i y_i \\
&\quad+ \sum_{i=1}^N p_{i} \int_{T_i}^{T} u_i(t-T_i)\,dt\\
&\quad+ h\int_{0}^T \left[\theta\frac{M - I(t)}{M}K(t) - D(t)\right]^+ dt,
\end{aligned}
\end{equation}
subject to
\begin{align}
K(t) &= \sum\nolimits_{i=1}^N u_i(t-T_i),
&& t\in [0,T]
\label{eq:2} \\
u_i(t) &\le % \theta_i S_i(t) y_i =
\theta_i (M_i - I_i(t)) y_i,
&& i = 1,\ldots, N,
\quad t\in [0,T-T_i]
\label{eq:ui} \\ \myequations{ui}
u_i(t) &= 0,
&& i = 1,\ldots, N,
\quad t\in [T-T_i,T]
\label{eq:uio} \\ \myequations{uio}
\dot{I}_i(t) &= f_i(I_i(t)),
&& i = 1,\ldots,N,
\quad t\in [0,T]
\label{eq:dotIi} \\ \myequations{dotIi}
\dot{I}(t) &= f(I(t)),
&& t\in [0,T]
\label{eq:dotI}\\ \myequations{dotI}
u_i(t) &\ge 0,
&& i = 1,\ldots,N,
\quad t\in [0,T]
\label{eq:const5} \\ \myequations{const5}
K(t) &\ge 0,
&& t\in [0,T] \\
y_i &\in \{0,1\},
&& i = 1,\ldots,N
\label{eq:const6}
\end{align} \myequations{const6}
where
\begin{equation}
\label{eq:capacity constraint}
\myequations{Capacity constraint}
u^{j}_i(t) \leq \min_{p\in C^{j}_{i}} \sum_{k \in {K^{j}_{ip}}} u^{j+1}_k(t-T_k)
\end{equation}
\end{document}
답변2
Mico가 언급했듯이 \label
. 레이블을 제공하지 않으려면 두 가지를 모두 수행하는 간단한 명령을 만들 수 있습니다. 나는 \ref
ams 정렬 내에서 올바른 번호를 선택하기 위해 여기를 사용했습니다.
\documentclass[english]{article}
\setcounter{secnumdepth}{2}
\usepackage{mathtools} % for \coloneqq and \mathclap macros
\usepackage{tocloft}
\usepackage[unicode=true, pdfusetitle, bookmarks=true,
bookmarksnumbered=false, bookmarksopen=false,
breaklinks=false, backref=false,
colorlinks=true,allcolors=black]
{hyperref}
\usepackage[noabbrev]{cleveref}
\counterwithin{equation}{section}
\newcommand{\listequationsname}{\normalsize List of Equations}
\newlistof{myequations}{equ}{\listequationsname}
\newcommand{\myequations}[1]{%
\addcontentsline{equ}{myequations}%
{\protect\numberline{\ref{eq:#1}}#1}}
\setlength{\cftmyequationsnumwidth}{2.5em}
\newcommand\myeq[1]{\label{eq:#1}\myequations{#1}}
\begin{document}
%\tableofcontents
\listofmyequations
\allowdisplaybreaks
\section{Section title}
\begin{gather}
F=q[E+(v\times B)]
\myeq{Force} \\
\tau=F\times r
\myeq{Torque}
\end{gather}
If the electrical force in \cref{eq:Force} is ignored, and
if the remaining magnetic force is used in \cref{eq:Torque},
with the assumption that $v$ is perpendicular to~$B$, we
find that
\begin{equation}
\tau=qvBr\sin\theta
\myeq{Magnetic}
\end{equation}
\begin{equation}
\myeq{objective function}
\begin{aligned}[t]
\smash[b]{\min_{\mathclap{%
\substack{u_{i}(t),y_i,\\ i=1,\dots,N}}}}
\,J(u_i(t),y_i)
&\coloneqq \sum_{i=1}^N \int_0^{T} R_i(u_{i}(t),t)\, dt
\\
&\quad+ \xi \int_{0}^{T} \left(\theta\frac{M - I(t)}{M}K(t) - D(t)\right)^{\!2} dt
+ \sum_{i=1}^N \gamma_i y_i \\
&\quad+ \sum_{i=1}^N p_{i} \int_{T_i}^{T} u_i(t-T_i)\,dt\\
&\quad+ h\int_{0}^T \left[\theta\frac{M - I(t)}{M}K(t) - D(t)\right]^+ dt,
\end{aligned}
\end{equation}
subject to
\begin{align}
K(t) &= \sum\nolimits_{i=1}^N u_i(t-T_i),
&& t\in [0,T]
\label{eq:2} \\
u_i(t) &\le % \theta_i S_i(t) y_i =
\theta_i (M_i - I_i(t)) y_i,
&& i = 1,\ldots, N,
\quad t\in [0,T-T_i]
\myeq{ui} \\
u_i(t) &= 0,
&& i = 1,\ldots, N,
\quad t\in [T-T_i,T]
\myeq{uio} \\
\dot{I}_i(t) &= f_i(I_i(t)),
&& i = 1,\ldots,N,
\quad t\in [0,T]
\myeq{dotIi} \\
\dot{I}(t) &= f(I(t)),
&& t\in [0,T]
\myeq{dotI}\\
u_i(t) &\ge 0,
&& i = 1,\ldots,N,
\quad t\in [0,T]
\myeq{const5} \\
K(t) &\ge 0,
&& t\in [0,T] \\
y_i &\in \{0,1\},
&& i = 1,\ldots,N
\myeq{const6}
\end{align}
where
\begin{equation}
\myeq{capacity constraint}
u^{j}_i(t) \leq \min_{p\in C^{j}_{i}} \sum_{k \in {K^{j}_{ip}}} u^{j+1}_k(t-T_k)
\end{equation}
\end{document}