Text Formattingifthen problem -- \thechapter & appendices

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
anthard
Posts: 2
Joined: Sun May 23, 2010 10:38 am

ifthen problem -- \thechapter & appendices

Post by anthard »

Hi,

I have a probem with the ifthen package. I use it with the fancyhdr package like this :

Code: Select all

\usepackage{nopageno}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\lhead{\ifthenelse{\thechapter > 0}{Expérience \thechapter}{}} \rhead{\thepage} \chead{}
I use the ifthenelse condition because in some cases, \thechapter = 0 and I don't want in my header the have the text "Expérience 0".
The problem is that at the end of my document, I use an appendices environment and at this moment, latex sent me the error :
! Missing number, treated as zero.
<to be read again>
>
l.x \begin{appendices}
I imagine that this problem comes because at some points of my document, \thechapter is undefined but I don't know who to surpass this problem.

I would really appreciate your help.
Regards,
Anthard_


My code :

Code: Select all

\documentclass[12pt,a4paper]{book}

\usepackage[french]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[margin=3cm]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\everymath{\displaystyle\everymath{}}
\usepackage{graphicx}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
\renewcommand{\baselinestretch}{1.2}

\usepackage{epsfig}

%%% Caption : %%%
\usepackage[margin=10pt,font=small,labelfont=bf,textfont=sl,labelsep=endash]{caption}

%%% Tableau : %%%
\setlength{\doublerulesep}{\arrayrulewidth}

%%% Chapitre : %%%
\addto\captionsfrench{\renewcommand\chaptername{Expérience}}

%%% Fancyhdr : %%%
\usepackage{nopageno}
\usepackage{fancyhdr}
\usepackage[Lenny]{sty/fncychap}
\pagestyle{fancy}
\fancyhf{}
\usepackage{ifthen}
\usepackage{calc}
\renewcommand{\headrulewidth}{0.4 pt}
\renewcommand{\footrulewidth}{0.4 pt}
\lhead{\ifthenelse{\thechapter > 0}{Expérience \thechapter}{}} \rhead{\thepage} \chead{} 

%%% Appendices : %%%
\usepackage[toc,page]{appendix}

\begin{document}

\chapter{Expérience 1}

\chapter{Expérience 2}

\chapter{Expérience 3}


\begin{appendices}
\section{App1}
\section{App2}
\end{appendices}

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

ifthen problem -- \thechapter & appendices

Post by localghost »

Modify the declaration for the left head as shown below.

Code: Select all

\lhead{\ifthenelse{\value{chapter}>0}{Expérience \thechapter}{}}
Best regards and welcome to the board
Thorsten
anthard
Posts: 2
Joined: Sun May 23, 2010 10:38 am

Re: ifthen problem -- \thechapter & appendices

Post by anthard »

Hi Thorsten,

It works, thanks a lot ! (happy to be on board.. :-))

Regards,
Anthard_
Post Reply