2

I made a book, kind of diccionary, about a subject. For the table-of-contents I am using the star-version \chapter*{nameofchapter}, so I would like to remove "nameofchapter" from the first page of each chapter but, generating an entrance in the table-of-contents. My code:

\documentclass{book}
\usepackage[left=1.5cm,right=1.5cm]{geometry}
\usepackage[spanish]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[table]{xcolor}
\usepackage{booktabs,newtxtext,newtxmath,multirow}
\usepackage{ltablex,mathabx}
\usepackage{hyperref}
\hypersetup{colorlinks=,linkcolor=darkblue2}
\pagecolor{white}
\usepackage{pdfpages,graphics}
%
\newcommand\VRule[1][\arrayrulewidth]{\vrule width #1}
\def\sr{\specialrule{.7pt}{0pt}{0pt}}
\def\di{$\diamond$}
\newcommand{\np}[1]{$^\mathbf{#1}$}
%
\definecolor{lilita}    {RGB}{215,205,247}
\definecolor{darkblue2} {rgb}{0,0,0.7}
%
\begin{document}
\includepdf[pages=2]{portadas}
\pagecolor{lilita}
\tableofcontents
\includepdf[pages=4]{portadas}
\include{i}
\includepdf[pages=5]{portadas}
\include{u}
\end{document}

that produces: MWE. So in this MWE what I would like is to "remove" the 'I' in p5, and the 'U' in p7, but keeping the hyperlinks in the table of contents. In file 'i.tex' I'm using:

\chapter*{I}
\addcontentsline{toc}{chapter}{I}

and the same in file 'u.tex'. The file 'portadas.pdf': portadas. Also, if it is possible, how do I change the color of "Índice General" to my 'darkblue2' color?

2
  • 1
    You can use \addcontentsline without \chapter if you don't want the chapters to be marked as such in the body text. Also, this MWE isn't actually minimal: it requires loading a bunch of packages that have nothing to do with the issue. Jun 10, 2018 at 4:56
  • Very cool artwork!
    – Mico
    Jun 16, 2018 at 6:05

1 Answer 1

4

Some suggestions:

  • Don't use \chapter* directives in i.tex, u.tex, etc. Instead, write something such as

    % i.tex  %% loaded via an \include statement
    %\chapter*{I} % <-- no longer needed
    \phantomsection
    \addcontentsline{toc}{chapter}{I}
    
    Chapter I material ...
    
  • Regarding the appearance of the table of contents: Since you also have \hypersetup{colorlinks,linkcolor=darkblue2}, setting the page color of the Table of Contents page to darkblue as well will make toc entries literally invisible. Not the intended effect, I assume. So, either choose a different page color or a different link color. To change the page color on the ToC page, you could replace the directive \tableofcontents with

    \cleardoublepage
    \pagecolor{yellow} % or whatever color is deemed appropriate
    \tableofcontents
    \clearpage
    
  • In addition, you should probably either run \pagestyle{plain} in the preamble or do something more with the running headers.

Aside: I had to comment out the instruction that loads the mathabx package in order to avoid getting a whole bunch of warning messages. Do you really need this package? If so, load it at an earlier stage in the preamble.

8
  • 1
    @AntonioOrtiz - Did you include the instruction \pagestyle{plain}, as I suggested? That should suppress the running headers. (If placing this instruction in the preamble doesn't work, try placing it immediately after \begin{document}.) To get "Índice General" to be typeset in darkblue2, I suggest you load the sectsty package and run the instruction \chapterfont{\color{darkblue2}}.
    – Mico
    Jun 10, 2018 at 21:40
  • 1
    @AntonioOrtiz - I suppose you could give \renewcommand{\thepage}{\textcolor{darkblue2}{\arabic{page}} a try.
    – Mico
    Jun 10, 2018 at 21:59
  • 1
    It's working! I thank you so much for your advice. Cheers! :) Jun 10, 2018 at 22:42
  • 1
    Hi Mico, can you have a look at this as well?
    – Johannes_B
    Jun 16, 2018 at 5:46
  • 1
    I deleted the post 'cause it is answered here. Thank you :-) Jun 16, 2018 at 12:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .