下午好
我有页面,每个页面都有\section*{...text...}
。我想列出这些部分的名称和页码。我可以自动完成吗?只需一个命令。
你知道吗?
\documentclass[10pt,a6paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[main=english,slovak]{babel}
\usepackage[cm]{fullpage}
\usepackage[a6paper, top=10mm, left=10mm, right=10mm,
bottom=10mm,foot=5mm,marginparsep=0mm,showframe]{geometry}
\usepackage{tipa}
\usepackage{tabularx,booktabs}
\usepackage{multirow}
\usepackage{rotating}
\usepackage{graphicx}
\usepackage{array}
\begin{document}
\catcode`\-=12
\sloppy
\section*{\foreignlanguage{slovak}{A}}
\newpage
\section*{\foreignlanguage{slovak}{B}}
\newpage
\section*{\foreignlanguage{slovak}{C}}
\newpage
\section*{\foreignlanguage{slovak}{D}}
\newpage
\section*{\foreignlanguage{slovak}{E}}
\newpage
\end{document}
答案1
也许这是一个可能的解决方案,使用用's\section*{foo}*
定义的变体——语法不寻常,但正常情况得以保留。xparse
\NewDocumentCommand
\section*
\documentclass[10pt,a6paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[main=english,slovak]{babel}
\usepackage[cm]{fullpage}
\usepackage[a6paper, top=10mm, left=10mm, right=10mm,
bottom=10mm,foot=5mm,marginparsep=0mm,showframe]{geometry}
\usepackage{tipa}
\usepackage{tabularx,booktabs}
\usepackage{multirow}
\usepackage{rotating}
\usepackage{graphicx}
\usepackage{array}
\usepackage{xparse}
\providecommand{\phantomsection}
\makeatletter
\let\latex@@section\section
\RenewDocumentCommand{\section}{soms}{%
\IfBooleanTF{#1}{%
\IfBooleanT{#4}{%
\addcontentsline{toc}{section}{{#3}}%
}%
\latex@@section*{#3}%
}{%
\IfValueTF{#2}{%
\latex@@section[#2]{#3}%
}{%
\latex@@section{#3}%
}
}%
}
\makeatother
\begin{document}
\tableofcontents
\catcode`\-=12
\sloppy
\section*{\foreignlanguage{slovak}{A}}*
\newpage
\section*{\foreignlanguage{slovak}{sobota}}*
\newpage
\section*{\foreignlanguage{slovak}{nedel'a}}*
\newpage
\section*{\foreignlanguage{slovak}{D}}*
\newpage
\section*{\foreignlanguage{slovak}{E}}*
\newpage
\end{document}