标准列表样式的方程式列表

标准列表样式的方程式列表

我在用着此解决方案生成方程式列表。

运行下面的最小示例,我想更改两点:

[A] 使用标准的“列表”样式,意味着:在标题后使用相同的空格,并像图形列表一样缩进条目。

[B] 使用单独的变量作为标题而不是标签

\documentclass[
    pdftex,
    listof=totoc,
]{scrreprt}

\usepackage{amsmath}
\usepackage{xstring}
\usepackage{tocloft}
\usepackage{blindtext}
\usepackage[demo]{graphicx}

\makeatletter
\numberwithin{equation}{chapter}

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

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 1}
    \label{fig:1}
\end{figure}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 2}
    \label{fig:2}
\end{figure}
\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 3}
    \label{fig:3}
\end{figure}

\blinddocument

\begin{equation}
1 + 1 = 2
\label{eq:first}
\end{equation}

\begin{equation}
2 + 2 = 4
\label{eq:second}
\end{equation}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 4}
    \label{fig:4}
\end{figure}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 5}
    \label{fig:5}
\end{figure}

\listoffigures
\listofmyequations

\end{document}

答案1

这种方法仅回答了您的问题[A](完整的解决方案请参阅下文)。

更换线路

\setlength{\cftmyequationsnumwidth}{3em}

\setlength{\cftmyequationsindent}{1.5em}
\setlength{\cftmyequationsnumwidth}{2.3em}

\listoffigures因此为了匹配中的相应定义tocloft.sty

\setlength{\cftfigindent}{1.5em}
\setlength{\cftfignumwidth}{2.3em}

梅威瑟:

\documentclass[
    pdftex,
    listof=totoc,
]{scrreprt}

\usepackage{amsmath}
\usepackage{xstring}
\usepackage{tocloft}
\usepackage{blindtext}
\usepackage[demo]{graphicx}

\makeatletter
\numberwithin{equation}{chapter}

% 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{\cftmyequationsindent}{1.5em}
\setlength{\cftmyequationsnumwidth}{2.3em}

\makeatother

\begin{document}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 1}
    \label{fig:1}
\end{figure}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 2}
    \label{fig:2}
\end{figure}
\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 3}
    \label{fig:3}
\end{figure}

\blinddocument

\begin{equation}
1 + 1 = 2
\label{eq:first}
\end{equation}

\begin{equation}
2 + 2 = 4
\label{eq:second}
\end{equation}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 4}
    \label{fig:4}
\end{figure}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 5}
    \label{fig:5}
\end{figure}

\listoffigures
\listofmyequations

\end{document} 

输出:

在此处输入图片描述


可以采用不同的方法来实现 [A] 和 [B]。

我不太喜欢这个,但是还是给了它。

我们使用该包float并将该Equation环境声明为一个新的浮动环境。

因此,将中间的所有内容替换\makeatletter ... \makeatother为:

\newfloat{Equation}{htbp}{equ}[chapter]
\newcommand{\listequationsname}{List of Equations}

此时您可以Equation按如下方式使用里面的方程式:

\begin{Equation}[!htb]
\centering
\begin{equation}
1 + 1 = 2
\end{equation}
\caption{First equation}
\label{eq:first}
\end{Equation}

要打印方程式列表,您必须写入以下行:

\listof{Equation}{\listequationsname}

代替

\listofmyequations

梅威瑟:

\documentclass[
    pdftex,
    listof=totoc,
]{scrreprt}

\usepackage{amsmath}
\usepackage{xstring}
\usepackage{float}
\usepackage{blindtext}
\usepackage[demo]{graphicx}

\newfloat{Equation}{htbp}{equ}[chapter]
\newcommand{\listequationsname}{List of Equations}

\begin{document}

\begin{Equation}[!htb]
\centering
\begin{equation}
0 + 0 = 0
\end{equation}
\caption{Zeroth equation}
\label{eq:zeroth}
\end{Equation}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 1}
    \label{fig:1}
\end{figure}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 2}
    \label{fig:2}
\end{figure}
\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 3}
    \label{fig:3}
\end{figure}

\blinddocument

\begin{Equation}[!htb]
\centering
\begin{equation}
1 + 1 = 2
\end{equation}
\caption{First equation}
\label{eq:first}
\end{Equation}

\begin{Equation}[!htb]
\centering
\begin{equation}
2 + 2 = 4
\end{equation}
\caption{Second equation}
\label{eq:second}
\end{Equation}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 4}
    \label{fig:4}
\end{figure}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 5}
    \label{fig:5}
\end{figure}

\listoffigures
\listof{Equation}{\listequationsname}

\end{document} 

输出:

在此处输入图片描述

相关内容