删除目录中 LoF/LoT 的页码

删除目录中 LoF/LoT 的页码

我想删除目录中 LoF 和 LoT 的链接页码。页码应该从第一章开始显示。

\documentclass[listof = totoc]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage{graphicx, duckuments}
\usepackage{scrlayer-scrpage}
\usepackage{hyperref}

\begin{document}

    \hypersetup{pageanchor=false}
    \pagestyle{empty}
    \renewcommand*{\chapterpagestyle}{empty}

    \tableofcontents % no page number for lof, lot wanted inside toc
    \listoffigures

    \cleardoubleoddpage
    \pagestyle{scrheadings}
    \renewcommand*{\chapterpagestyle}{plain}
    \hypersetup{pageanchor=true}
    \pagenumbering{arabic}

    \duckument

    \begin{figure}
        \includegraphics{example-image-duck}
        \caption{I'm a random duck}
    \end{figure}
\end{document}

指的是底部的实际页码。我指的是打印在右侧的数字\tableofcontents在此处输入图片描述

答案1

这里有两条建议。

您可以在代码中使用开关tocpagenumberformat

\documentclass[listof = totoc]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{duckuments}% only for dummy text
\usepackage{scrlayer-scrpage}
\usepackage{hyperref}
\hypersetup{hypertexnames=false}

\RedeclareSectionCommand[
  tocpagenumberformat=\tocchapterpagenumberformat
]{chapter}

\newif\ifgobblechaptertocpagenumber
\newcommand*\tocchapterpagenumberformat[1]
  {{\ifgobblechaptertocpagenumber\else{\usekomafont{chapterentrypagenumber}#1}\fi}}

\begin{document}
\hypersetup{pageanchor=false}
\renewcommand*\chapterpagestyle{empty}
\pagestyle{empty}
\addtocontents{toc}{\protect\gobblechaptertocpagenumbertrue}

\tableofcontents % no page number for lof, lot wanted inside toc
\listoffigures

\cleardoubleoddpage
\hypersetup{pageanchor=true}
\pagenumbering{arabic}
\renewcommand\chapterpagestyle{plain}
\pagestyle{scrheadings}
\addtocontents{toc}{\protect\gobblechaptertocpagenumberfalse}
\duckument
\begin{figure}
    \includegraphics{example-image-duck}
    \caption{I'm a random duck}
\end{figure}
\end{document}

在此处输入图片描述

或者,您可以为列表定义一个新的条目listchapter和补丁来使用:\addchaptertocentrylistchapterchapter

\documentclass[listof= totoc]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{duckuments}% only for dummy text
\usepackage{scrlayer-scrpage}
\usepackage{hyperref}

\DeclareTOCStyleEntry[
  level=\chaptertocdepth,
  indent=0pt,
  numwidth=1.5em,
  pagenumberformat=\gobblepagenumber
]{chapter}{listchapter}
\newcommand\gobblepagenumber[1]{}
\usepackage{xpatch}
\BeforeTOCHead{%
  \xpatchcmd{\addchaptertocentry}{chapter}{listchapter}{}{\addchapPatchFailed}%
}

\begin{document}
\hypersetup{pageanchor=false}
\pagestyle{empty}
\renewcommand*{\chapterpagestyle}{empty}

\tableofcontents % no page number for lof, lot wanted inside toc
\listoffigures

\cleardoubleoddpage
\hypersetup{pageanchor=true}
\pagenumbering{arabic}
\pagestyle{scrheadings}
\renewcommand*{\chapterpagestyle}{plain}

\duckument
\begin{figure}
    \includegraphics{example-image-duck}
    \caption{I'm a random duck}
\end{figure}
\end{document}

结果和上面一样。

相关内容