找到后方程表和http://www.latex-community.org/forum/viewtopic.php?f=5&t=428,我开始制作一个方程式列表我的文档。问题在于我们已经有了一份工作草案,它有数百页,包含几十个方程式。
上面的链接描述了如何使用托克洛夫特添加方程式列表,但两者都要求在每个方程后面加上标签,例如\myequations{Display name}
。为了避免必须为所有方程添加此标签,我重新定义equation
为自动包含我们的\myequations{}
命令:
\let\oldequation = \equation
\let\endoldequation = \endequation
\renewenvironment{equation}{
\begin{oldequation}
}{
\end{oldequation}
\myequations{\@currentlabelname}
}
我继续托克洛夫特- 特定代码直接基于上述链接,结尾为:
\usepackage{tocloft}
\newcommand{\listequationsname}{List of Equations}
\newlistof{myequations}{equ}{\listequationsname}
% myequation takes in its display name
\newcommand{\myequations}[1]{
% display name is printed
\addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}\par}
然后所有\equation
s 将自动出现在方程式列表。这很好,但是有一个问题:
每个\equation
人显示的名字方程式列表不是其自身的\label
(例如“扭矩”)而是它出现的名称\subsection
(例如,数十个方程式都具有“直流电机操作”等名称)
有什么想法吗?我可以用什么\@currentlabelname
来替换方程式的名称\label
?一个简单的方程式如下所示:
\begin{equation}
\tau=F\times r
\label{eq:Torque}
\end{equation}
顺便说一句,我实际上是在 Lyx 中这样做的,但这似乎不是我的问题的根源。事实上,如果有更优雅的 Lyx 解决方案,我愿意倾听。
谢谢!
LaTeX 中的示例:
\documentclass[english]{article}
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
\usepackage{amsmath}
\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
\renewenvironment{equation}{
\begin{oldequation}
}{
\end{oldequation}
\myequations{\@currentlabelname}
}
% try to make a List of Equations,
% error is most likely in the @currentlabelname above
\usepackage{tocloft}
\newcommand{\listequationsname}{List of Equations}
\newlistof{myequations}{equ}{\listequationsname}
\newcommand{\myequations}[1]{
\addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}\par}
\setlength{\cftmyequationsnumwidth}{3em}
\makeatother
\begin{document}
\tableofcontents{}
\listofmyequations
\section{Brushless Motor Fundamentals}
\subsubsection{DC Motor Operation}
Torque is generated in DC motors from the magnetic force,
also known as the Lorentz force, which is produced when an
electric current is passed through a coil in a magnetic field.
This force is given by \ref{eq:Force}.
\begin{equation}
F=q[E+(v\times B)]
\label{eq:Force}
\end{equation}
where F is the force perpendicular to the coil,
E is the electric field in the coil,
v is the velocity of the charged particles in the coil,
and B is the magnetic field. From mechanics, torque is
\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}
\end{document}
[已修复 - 谢谢麦克伦弗洛] 公式 2.1 - 2.9 在方程式列表但是在方程式编号达到 2.10 之后,最后一位数字(“个位”)与显示名称的开头重叠。
答案1
这是 Lev Bishop 代码的修改版本;我使用了字符串包从标签中删除字符串“eq:”:
\documentclass[english]{article}
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
\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}
\newcommand{\listequationsname}{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{Brushless Motor Fundamentals}
\subsubsection{DC Motor Operation}
Torque is generated in DC motors from the magnetic force,
also known as the Lorentz force, which is produced when an
electric current is passed through a coil in a magnetic field.
This force is given by \ref{eq:Force}.
\begin{equation}
F=q[E+(v\times B)]
\label{eq:Force}
\end{equation}
where $F$ is the force perpendicular to the coil,
$E$ is the electric field in the coil,
$v$ is the velocity of the charged particles in the coil,
and $B$ is the magnetic field. From mechanics, torque is
\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}
\end{document}
答案2
这是示例的修改版本。主要变化是我\label
在方程环境中重新定义:
\documentclass[english]{article}
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
\usepackage{amsmath}
\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]{\myequations{#1}\oldlabel{#1}}
\renewenvironment{equation}{%
\oldequation
\let\label\mynewlabel
}{\endoldequation}
% try to make a List of Equations,
% error is most likely in the @currentlabelname above
\usepackage{tocloft}
\newcommand{\listequationsname}{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{Brushless Motor Fundamentals}
\subsubsection{DC Motor Operation}
Torque is generated in DC motors from the magnetic force,
also known as the Lorentz force, which is produced when an
electric current is passed through a coil in a magnetic field.
This force is given by \ref{eq:Force}.
\begin{equation}
F=q[E+(v\times B)]
\label{eq:Force}
\end{equation}
where F is the force perpendicular to the coil,
E is the electric field in the coil,
v is the velocity of the charged particles in the coil,
and B is the magnetic field. From mechanics, torque is
\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}
\end{document}
答案3
我扩展了以前的答案来定义一个您可以像这样使用的命令:
\noteworthy{a^2 + b^2 = c^2}{Pythagorean theorem}
而且它会自动标记、引用、框出和列出我认为值得注意的方程式。我对结果非常满意。
请注意,红色方块仅突出显示超链接,它们在 pdf 上不可见。
然后对方程式进行编号、框选、标记文字(与方程式列表相匹配),并贴上标签以便我们引用它。
最小可行示例:
\documentclass{article}
\usepackage{tocloft} % for list of equations
\usepackage{ragged2e} % to undo \centering
\usepackage{hyperref} % to make references hyperlinks
\usepackage{glossaries}
% define list of equations
\newcommand{\listequationsname}{\Large{List of Equations}}
\newlistof{myequations}{equ}{\listequationsname}
\newcommand{\myequations}[1]{
\addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}
}
\setlength{\cftmyequationsnumwidth}{2.3em}
\setlength{\cftmyequationsindent}{1.5em}
% command to box, label, reference, and
% include noteworthy equation in list of equations
\newcommand{\noteworthy}[2]{
\begin{align} \label{#2} \ensuremath{\boxed{#1}} \end{align}
\myequations{#2} \centering \small \textit{#2} \normalsize \justify }
\begin{document}
\listofmyequations \pagebreak
\noteworthy{P(\bigcup_{n=1}^n A_n) \leq \sum_{n=1}^n P(A_n)}{Boole's inequality}
Where the events $A_n$ are disjoint, then the inequality
in equation \ref{Boole's inequality} becomes an equality.
\end{document}
答案4
我还无法在常规 LaTeX 中提出一个最小的工作示例。
至于 (2),尝试设置\cftmyequationsnumwidth
为更大的值(参见 tocloft 手册,第 2.3 节)。