如何在目錄中使用數字而不是標題

如何在目錄中使用數字而不是標題

我想在目錄中的特殊部分使用圖形(小圖示)。您有什麼建議嗎?通常我用它 \addcontentsline{toc}{section}{Name} 來引用目錄。

答案1

ToC由於它是一個(特殊)文件,因此基本上沒有什麼具體的信息寫入.tex- 然而,與往常一樣,寫入文件時,內容應該變得健壯或使用\protect脆弱的命令,例如\includegraphics.

\documentclass{article}
\usepackage{graphicx}

\begin{document}
\tableofcontents
\section{Foo}
\addcontentsline{toc}{section}{\protect\includegraphics[scale=0.2]{beeduck}}
\section{Other foo}
\end{document}

在此輸入影像描述

答案2

\documentclass{scrartcl}
\usepackage{graphicx}

\begin{document}
    \tableofcontents
    \section{Foo}
    \addsec[{\protect\includegraphics[width=1cm]{tiger}}]{}
    \section{Other foo}
\end{document}

在此輸入影像描述

相關內容