0

I've this code. The problem is the space above \tableofcontents, different from the space above \listoffigure and \listoftables. The spaces above \listoffigures and \listoftables are less than spaces above \tableofcontents. How to reduce the space in \listoffigures and listoftables so the space (with above \tableofcontents) same?

\documentclass[a4paper]{book}
    \usepackage{tocbasic}
    \renewcommand{\contentsname}{DAFTAR ISI}
    % Redefinition of ToC command to get centered heading
    \makeatletter
    \renewcommand\tableofcontents{%
      \cleardoublepage\null\vspace{-12pt}\hfill\textbf{\large\contentsname}\hfill\null\par
      \@mkboth{\MakeUppercase\contentsname}{\MakeUppercase\contentsname}%
      \vspace{30pt}
      \@starttoc{toc}%
    }
    \makeatother

    \usepackage{eqparbox} %membuat spasi chapter rata

    \usepackage{titletoc}%
    \titlecontents{chapter}% <section-type>
      [0pt]% <left>
      {\vspace{12pt}\bfseries}% <above-code>
      {\eqmakebox[TC][l]{\chaptername~\thecontentslabel }\quad}% <numbered-entry-format>
      {}% <numberless-entry-format>
      {\hfill\contentspage}[\vspace{0pt}]

      \titlecontents{section}[27mm]   
        {\vspace{0pt}\normalsize\normalfont} 
        {\contentslabel[\thecontentslabel]{24pt}}{}
        {\titlerule*[.75em]{.}{\contentspage}}  

      \titlecontents{subsection}[38mm]   
        {\vspace{0pt}\normalsize\normalfont} 
        {\contentslabel[\thecontentslabel]{30pt}}{}
        {\titlerule*[.75em]{.}{\contentspage}}  
    %listoffigures
    \renewcommand{\listfigurename}{DAFTAR GAMBAR}
    \cleardoublepage
    \makeatletter
    \renewcommand\listoffigures{{%
      \let\oldnumberline\numberline%
      \renewcommand{\numberline}{\figurename~\oldnumberline}%
      \null\vspace{-24pt}\hfill\textbf{\fontsize{14}{12}\selectfont\listfigurename}\hfill\null\par
      \@mkboth{\MakeUppercase\listfigurename}{\MakeUppercase\listfigurename}%
      \vspace{20pt}

        \@starttoc{lof}%
    }}

    \titlecontents{figure}
      [2.5cm]
      {\addvspace{12pt}}
      {\makebox[0pt][r]{%
          \makebox[2.4cm][l]{Gambar~\thecontentslabel}%
        }%
      }
      {\hspace{-1.7cm}}
      {\titlerule*[6pt]{.}\contentspage}

    % from https://tex.stackexchange.com/a/275577:
    \usepackage{xpatch}
    \makeatletter
    \xpatchcmd{\@chapter}{%
      \addtocontents{lof}{\protect\addvspace{10\p@}}%
      \addtocontents{lot}{\protect\addvspace{10\p@}}%
    }{}{}{}
    \makeatother

    %listoftables
    \renewcommand{\listtablename}{DAFTAR TABEL}
    \cleardoublepage{}
    \makeatletter
    \renewcommand\listoftables{%
      \null\hfill\textbf{\large\listtablename}\hfill\null\par
      \@mkboth{\MakeUppercase\listtablename}{\MakeUppercase\listtablename}%
      \vspace{20pt}

        \@starttoc{lot}%
    }
    \renewcommand{\listtablename}{DAFTAR TABEL}
    \cleardoublepage{}
    \makeatletter
    \renewcommand\listoffigures{{%
      \let\oldnumberline\numberline%
      \renewcommand{\numberline}{\figurename~\oldnumberline}%
      \null\hfill\textbf{\large\listfigurename}\hfill\null\par
      \@mkboth{\MakeUppercase\listfigurename}{\MakeUppercase\listfigurename}%
      \vspace{20pt}

        \@starttoc{lof}%
    }}
    \titlecontents{table}
      [2.5cm]
      {\addvspace{12pt}}
      {\makebox[0pt][r]{%
          \makebox[2.4cm][l]{Tabel~\thecontentslabel}%
        }%
      }
      {\hspace{-1.7cm}}
      {\titlerule*[6pt]{.}\contentspage}

    % from https://tex.stackexchange.com/a/275577:
    \usepackage{xpatch}
    \makeatletter
    \xpatchcmd{\@chapter}{%
      \addtocontents{lof}{\protect\addvspace{10\p@}}%
      \addtocontents{lot}{\protect\addvspace{10\p@}}%
    }{}{}{}
    \makeatother
    \begin{document}
    \tableofcontents
    \cleardoublepage
    \listoftables
    \cleardoublepage
    \listoffigures
    \end{document}
Bernard
  • 271,350
Eddy
  • 98
  • Instead of redefining \tableofcontents, you should redefine @makeschapterhead (inside a group to be safe). – John Kormylo Dec 15 '19 at 15:51
  • Can you explain more? I don't get it – Eddy Dec 16 '19 at 05:33
  • In your preamble you redefined \tableofcontents to change the spacing. However, the normal \tableofcontents (book class) uses \chapter{\contentswname}, while \listoffigures use \chapter{\listfigurename} etc. These are formatted using @makeschapterhead. – John Kormylo Dec 16 '19 at 14:50
  • Can you write example project? – Eddy Dec 16 '19 at 16:25

1 Answers1

0

I simply copied all the titletoc stuff without checking or testing.

\documentclass[a4paper]{book}
    \usepackage{tocbasic}
    \renewcommand{\contentsname}{DAFTAR ISI}
    % Redefinition of \chapter* to change spacing and center title
\makeatletter
\def\@makeschapterhead#1{%
  \vspace*{-12\p@}% originally 50pt
  {\centering% could take more than one line
    \normalfont
    \interlinepenalty\@M
    \Huge \bfseries  #1\par\nobreak
    \vskip 30\p@% originally 40pt
  }}
\makeatother

    \usepackage{eqparbox} %membuat spasi chapter rata

    \usepackage{titletoc}%
    \titlecontents{chapter}% <section-type>
      [0pt]% <left>
      {\vspace{12pt}\bfseries}% <above-code>
      {\eqmakebox[TC][l]{\chaptername~\thecontentslabel }\quad}% <numbered-entry-format>
      {}% <numberless-entry-format>
      {\hfill\contentspage}[\vspace{0pt}]

      \titlecontents{section}[27mm]   
        {\vspace{0pt}\normalsize\normalfont} 
        {\contentslabel[\thecontentslabel]{24pt}}{}
        {\titlerule*[.75em]{.}{\contentspage}}  

      \titlecontents{subsection}[38mm]   
        {\vspace{0pt}\normalsize\normalfont} 
        {\contentslabel[\thecontentslabel]{30pt}}{}
        {\titlerule*[.75em]{.}{\contentspage}}  
    %listoffigures
    \renewcommand{\listfigurename}{DAFTAR GAMBAR}

    \titlecontents{figure}
      [2.5cm]
      {\addvspace{12pt}}
      {\makebox[0pt][r]{%
          \makebox[2.4cm][l]{Gambar~\thecontentslabel}%
        }%
      }
      {\hspace{-1.7cm}}
      {\titlerule*[6pt]{.}\contentspage}

    % from https://tex.stackexchange.com/a/275577:
    \usepackage{xpatch}
    \makeatletter
    \xpatchcmd{\@chapter}{%
      \addtocontents{lof}{\protect\addvspace{10\p@}}%
      \addtocontents{lot}{\protect\addvspace{10\p@}}%
    }{}{}{}
    \makeatother

    %listoftables
    \renewcommand{\listtablename}{DAFTAR TABEL}

    \titlecontents{table}
      [2.5cm]
      {\addvspace{12pt}}
      {\makebox[0pt][r]{%
          \makebox[2.4cm][l]{Tabel~\thecontentslabel}%
        }%
      }
      {\hspace{-1.7cm}}
      {\titlerule*[6pt]{.}\contentspage}

    \usepackage{showframe}

    \begin{document}
    \tableofcontents
    \listoftables
    \listoffigures

    \end{document}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120