LyXError in pdf generation, commands \headrule and \footrule

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
diazdeus
Posts: 32
Joined: Fri Sep 28, 2018 9:34 pm

Error in pdf generation, commands \headrule and \footrule

Post by diazdeus »

I have an error when I try to generate the pdf archive (ps2pdf) of my document. This is the error:

LaTeX error: Command \headrule already defined.
LaTeX error: Command \footrule already defined


This is the error description:

\newcommand\headrule{\setheadrule{.4\p@}}

This is the preamble:

Code: Select all

\date{}
\usepackage{fancyhdr}
\usepackage{ifthen}
\usepackage{graphicx}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{ccaption}
\usepackage[labelsep=endash,font={small,it},labelformat=simple,labelfont=bf,figurewithin=none,justification=centering]{caption}
\usepackage{textcomp}
\usepackage{nccparskip}
\usepackage{titlesec,titletoc,titleps}

\titleformat{\chapter}[display]
{\Large\bfseries\fillast\vspace{-25pt}}
{\normalfont\bfseries\chaptername\hspace{5pt}\thechapter}
{.5ex minus .1ex}
{\Large}[\vspace{-15pt}]

\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\vspace*{\fill}
\thispagestyle{empty}
\newpage 
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother
Last edited by Stefan Kottwitz on Fri Sep 28, 2018 10:26 pm, edited 1 time in total.

Recommended reading 2024:

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

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

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Error in pdf generation, commands \headrule and \footrule

Post by Stefan Kottwitz »

Hi,

welcome to the forum!

The packages fancyhdr and titleps cause a conflict. Remove one of then in your preamble. If you don't need titleps, don't load it via \usepackage.

Stefan
LaTeX.org admin
diazdeus
Posts: 32
Joined: Fri Sep 28, 2018 9:34 pm

Error in pdf generation, commands \headrule and \footrule

Post by diazdeus »

¡Thank you! Now, I can generate the final pdf archive. But I don't have the headers that I want; no header, it's blank. This is the code that I have used, just after of the \mainmatter command, to generate the headers. Is an even an odd document (two pages, side by side):

Code: Select all

\setlength{\headheight}{15pt}
\fancyhf{}
\fancyhead[LE,RO]{\fancyplain{}{\bfseries\thepage}}
\fancyhead[RE,LO]{\fancyplain{}{{\bfseries\chaptername \,\thechapter}-\,\itshape\thesection}}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
Last edited by Stefan Kottwitz on Fri Sep 28, 2018 11:20 pm, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Error in pdf generation, commands \headrule and \footrule

Post by Stefan Kottwitz »

I get headers with that code. Perhaps you did not set the twoside option to the document class. The headings are in twoside mode.

Stefan
LaTeX.org admin
Post Reply