General\renewcommand{\chaptername}{} does NOT work -- why?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
nvx
Posts: 25
Joined: Mon Dec 17, 2007 7:49 pm

\renewcommand{\chaptername}{} does NOT work -- why?

Post by nvx »

Hello everyone,
I am trying to get rid of (or rename) the "Chapter x" string before names of chapters. As far as I know, the command

Code: Select all

\renewcommand{\chaptername}{}
in the preamble should do the trick. Nevertheless, I can't get it to work. I have tried putting it into a new document with one chapter and the least possible number of loaded packages to avoid possible package "interference", but the result was the same -- the word "Chapter" is still there...

I wouldn't mind renaming the "Chapter" to "Part", since I'm writing a report and "Part" would be quite appropriate, but even if I use

Code: Select all

\renewcommand{\chaptername}{Part}
it still does not do what I want it to do.

I use MiKTeX and, I have never had problems with this system since this one. What am I doing wrong?

Thanks a lot for any help...


Best regards,
nvx

P.S.: Document class "article" is not an option, I unfortunately need more than just sections...

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

\renewcommand{\chaptername}{} does NOT work -- why?

Post by gmedina »

The problem can be the use of the babel package. Please consider the following examples:

1) This will change the \chaptername from chapter to part.

Code: Select all

\documentclass{report} 
\renewcommand\chaptername{Part}

\begin{document}
\chapter{First chapter}
\end{document}
2) This won't change the \chaptername from chapter to part.

Code: Select all

\documentclass{report} 
\usepackage[english]{babel}
\renewcommand\chaptername{Part}

\begin{document}
\chapter{First chapter}
\end{document}
3) When using the babel package you have to use the \addto commad, as the following code shows:

Code: Select all

\documentclass{report} 
\usepackage[english]{babel}
\addto\captionsenglish{%
 \renewcommand\chaptername{Part}}

\begin{document}
\chapter{First chapter}
\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

\renewcommand{\chaptername}{} does NOT work -- why?

Post by localghost »

First of all you should provide some code. The reason why your redefinition fails could come from the babel package. But to answer that clearly, I need to know your (complete) preamble.

An alternative could be using the classes of the KOMA Script Bundle. In these classes, the option nochapterprefix is set as default and results in the effect you want to have. For further information refer to the documentation.


Best regards and welcome on Board
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
nvx
Posts: 25
Joined: Mon Dec 17, 2007 7:49 pm

Re: \renewcommand{\chaptername}{} does NOT work -- why?

Post by nvx »

Thank you both for providing the hints. It was really due to the use of the "babel" package.

Best regards,
nvx
kalmer
Posts: 3
Joined: Sat Apr 02, 2022 9:58 pm

\renewcommand{\chaptername}{} does NOT work -- why?

Post by kalmer »

I get the following error:

Code: Select all

! Undefined control sequence.
<recently read> \addto 
The first example works well once the PDF-file is generated directly from TEX-file. However if that TEX-file is just part of a bookdown project then it doesn't do anything.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

\renewcommand{\chaptername}{} does NOT work -- why?

Post by Stefan Kottwitz »

Hi Kalmer,

welcome to the forum!

It seems that you did not load the babel package.

Stefan
LaTeX.org admin
Post Reply