latex \ part {}在toc中显示两次

时间:2014-08-15 13:17:56

标签: latex

我最近在LaTex中学会了编辑\part{}的显示,当我生成pdf时看起来很棒,但我的内容表中存在问题。

虽然一次显示\part*{},但在我的toc中显示\part{}两次。

例如,如果我输入

\part{Here is a part}

我会在我的toc中得到这个:

1. Here is a part    5

Here is a part       6

正确的页码是第二个(在这种情况下为6),但我想在toc中显示时仍然有1.这是我的部分定义代码

% --------------------------------------------------
% Paramétrage des parties
% --------------------------------------------------
\titleclass{\part}{straight}
\titleformat{\part}[frame]
    {\cleardoublepage\null\vspace{.10\textheight}\normalfont}
    {\filright
    \enspace PARTIE~\thepart\enspace}
    {8pt}
    {\huge\bfseries\filcenter\textsc}

\titlespacing{\part}{0pt}{*0}{*5}

\renewcommand\thepart{\arabic{part}}

你能告诉我我的代码有什么问题吗?

非常感谢您提前! :)

1 个答案:

答案 0 :(得分:0)

我无法准确地告诉您原因,但是您的定义中的\cleardoublepage会让您感到困惑 - 以下内容应该可以正常使用:

\documentclass{book}

\usepackage{titlesec}
\renewcommand\thepart{\arabic{part}}

%\titleclass{\part}{straight}
\titleformat{\part}[frame]
    {\null\vspace{.10\textheight}\normalfont}
%   {\cleardoublepage\null\vspace{.10\textheight}\normalfont}
    {\filright
    \enspace PARTIE~\thepart\enspace}
    {8pt}
    {\huge\bfseries\filcenter\textsc}

%\titlespacing{\part}{0pt}{*0}{*5}


% Comment the following to have chapters numbered without interruption (numbering through parts)
\makeatletter\@addtoreset{chapter}{part}\makeatother%

\begin{document}
    \tableofcontents
    \part{First part}
        \chapter{First chapter}
        \chapter{Second chapter}
        %...
        \chapter{Last chapter}
    \part{Second part}
        \chapter{First chapter}
        \chapter{Second chapter}
        %...
        \chapter{Last chapter}
    \part{Last part}
        \chapter{First chapter}
        \chapter{Second chapter}
        %...
        \chapter{Last chapter}
\end{document}

为了不让\part占据整个页面,但将其放在页面顶部附近(有一些间距),请使用以下\titleclass{\part}{top}设置部分的行为类似章节:

\documentclass{book}

\usepackage{lipsum}

\usepackage{titlesec}
\renewcommand\thepart{\arabic{part}}

\titleclass{\part}{top}
\titleformat{\part}[frame]
    {\normalfont}
    {\filright
    \enspace PARTIE~\thepart\enspace}
    {8pt}
    {\huge\bfseries\filcenter\textsc}

%\titlespacing{\part}{0pt}{*0}{*5}

% Comment the following to have chapters numbered without interruption (numbering through parts)
\makeatletter\@addtoreset{chapter}{part}\makeatother%

\begin{document}
    \tableofcontents
    \part{First part}
        \lipsum
    \part{Second part}
    \part{Last part}
\end{document}