2

I want to modify the chapter title in chapters without number (Namely, table of contents and bibliography). For this porpoise I used the following:

\def\@makeschapterhead#1{
   \fbox{\parbox{\linewidth}{\centering
      \large\bfseries #1
}}}

The problem is that now I cannot use the \tableofcontents command since it sends a warning stopping the compilation:

! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.4 ...umberline {1}CV D\'etaill\'e}{2}{chapter.1}

? error: unknown file type

It is just a warning, because by pressing enter, it continues compiling. But it is a quite annoying warning.

Any help?

3
  • It's not a warning. It is an error as you can see... What are you trying to achieve and with which document class? Mar 6, 2014 at 19:50
  • I am using report. What I am trying to achieve (and I achieve, as soon as I do not use \tableofcontents), is to have the chapter title of "Table of contents", and the chapter title of "Bibliography", with the given format: enclosed in an fbox, centred, with large size and bf. Mar 6, 2014 at 19:53
  • In fact, after the error, I press enter, and it continues, and everything work as expected: the titles are as I wanted, and the table of contents is correct. The only problem is the stop in the compilation each time I compile it! Mar 6, 2014 at 19:55

2 Answers 2

3

Redefine it in this way (you were missing a \par at least, and use \dimexpr\linewidth-2\fboxsep-2\fboxrule instead of simply \linewidth to avoid bad boxes)

\def\@makeschapterhead#1{%
   \noindent\fbox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{%
      \centering\large\bfseries #1%
}}\par\nobreak}

MWE:

\documentclass{report}

\makeatletter
\def\@makeschapterhead#1{%
   \noindent\fbox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{%
      \centering\large\bfseries #1%
}}\par\nobreak}
\makeatother

\begin{document}

\tableofcontents

\chapter{A chapter}

\end{document} 

Output:

enter image description here

2
  • Great. Thanks! Then my trick with center works only because it adds the missing \par. Mar 6, 2014 at 20:07
  • 1
    @AlejandroDíaz-Caro You're welcome, and you're right about that. :-) Mar 6, 2014 at 20:08
0

I just found the way to solve the problem (please, if somebody can explain to me why does it works, I will be delighted). I changed the definition of makeschapterhead by the following:

\def\@makeschapterhead#1{
  \begin{center}
    \fbox{\parbox{\linewidth}{\centering
      \large\bfseries #1
    }}
  \end{center}
}

That is, I just enclosed my definition in a center environment.

Odd.

You must log in to answer this question.

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