撤銷頁碼對齊並從演算法清單中刪除點

撤銷頁碼對齊並從演算法清單中刪除點

我正在使用經典論文主題,我試圖使我的演算法列表與我的表格和圖形列表的格式相同。我正在使用該algorithm2e包。這是目前的情況。

在此輸入影像描述

我已經嘗試過以下問題的答案這個問題但它們不起作用,大概是因為它們使用了該algorithm包。使用接受的答案,演算法列表採用圖形列表的名稱,但不列出任何內容:在此輸入影像描述

另一個答案根本沒有改變任何東西。

由於經典論文模板很大,我不確定如何提供最小的工作範例...以下程式碼使用classicthesis.sty經典論文模板中的原始文件重現了該問題。

\documentclass{scrreprt}

\usepackage{classicthesis}
\usepackage{algorithm2e}

\begin{document}

\listoftables
\listofalgorithms

\newpage

Here is Algorithm \ref{alg:some_alg}.

\begin{algorithm}
    \For{something}{
        something else
    }
    \caption{Some algorithm.}\label{alg:some_alg}
\end{algorithm}

Here is Table \ref{tab:some_table}.

\begin{table}
    \centering
    \begin{tabular}{cc}
    some line & some content \\
    some other line & some other content \\
    \end{tabular}
    \caption{Some table.}
    \label{tab:some_table}
\end{table}

\end{document}

我希望從演算法表中刪除點,並撤消頁碼的對齊方式,使其看起來像上面的表格列表。

答案1

關鍵是 tocloft 指令\newlistof。實際的格式化是由 執行的\l@algocf

\documentclass{scrreprt}

\usepackage{classicthesis}
\usepackage{algorithm2e}

\makeatletter
\newlistof{algorithms}{loa}{\listalgorithmcfname}%
    \renewcommand{\cftalgorithmsleader}{\hspace{1.5em}}%
    \renewcommand{\cftalgorithmsafterpnum}{\cftparfillskip}%
    \renewcommand{\cftalgorithmspresnum}{\algorithmcfname~}%
    \newlength{\algorithmslabelwidth}%
    \settowidth{\algorithmslabelwidth}{\cftalgorithmspresnum~999}%
    \addtolength{\algorithmslabelwidth}{2.5em}%
    \cftsetindents{algorithms}{0em}{\algorithmslabelwidth}%
    \let\l@algocf\l@algorithms
\makeatother

\begin{document}

\listoftables
\listofalgorithms

\newpage

Here is Algorithm \ref{alg:some_alg}.

\begin{algorithm}
    \For{something}{
        something else
    }
    \caption{Some algorithm.}\label{alg:some_alg}
\end{algorithm}

Here is Table \ref{tab:some_table}.

\begin{table}
    \centering
    \begin{tabular}{cc}
    some line & some content \\
    some other line & some other content \\
    \end{tabular}
    \caption{Some table.}
    \label{tab:some_table}
\end{table}

\end{document}

相關內容