Page LayoutFancy heading problem: section name to the left side

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
turbomac
Posts: 34
Joined: Sat Oct 10, 2009 9:38 pm

Fancy heading problem: section name to the left side

Post by turbomac »

Hi everyone:

I'm using the fancyhdr to make fancy headings but I can't make the section name to appear in the left side of the heading. This is the code (a part of it):

Code: Select all

\usepackage{fancyhdr}
\renewcommand{\sectionmark}[1]{%
\markboth{\sectionname
\ \thesection.\ #1}{}}


\headheight15pt

\pagestyle{fancy}


\fancyhead{} % clear all header fields
\fancyhead[RO]{PID}
\fancyhead[LE]{\bfseries \nouppercase{\sectionname}}
\fancyfoot{} % clear all footer fields
\fancyfoot[CE,CO]{\thepage}

\renewcommand{\headrulewidth}{1.5pt}
\renewcommand{\footrulewidth}{0pt}
The section name simply doesn't appear in the place where I want.
Any suggestions??
Thanks in advance.

Recommended reading 2024:

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

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

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Re: Fancy heading problem

Post by gmedina »

Please provide complete, compilable and minimal code (that, at least, will indicate the document class used).
1,1,2,3,5,8,13,21,34,55,89,144,233,...
turbomac
Posts: 34
Joined: Sat Oct 10, 2009 9:38 pm

Fancy heading problem: section name to the left side

Post by turbomac »

Sorry. Here is the code:

Code: Select all

\documentclass[letterpaper,12pt]{report}
\pagestyle{myheadings}
\usepackage[bottom]{footmisc}

\usepackage[left=2.3cm,top=2.3cm,right=2.3cm]{geometry}
\usepackage[activeacute,spanish] {babel}
\addto\captionsspanish{
        \def\listtablename{\'Indice de tablas}%
        \def\tablename{Tabla}} 

\usepackage{graphicx}
\usepackage{ucs}
%\usepackage[utf8x]{inputenc} %Codificacion de entrada
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc} %Codificacion de fuente
\usepackage{float}
\usepackage{amsmath}
\usepackage{amssymb}

\usepackage{fancyhdr}
\renewcommand{\sectionmark}[1]{%
\markboth{\sectionname
\ \thesection.\ #1}{}}


\headheight15pt

\pagestyle{fancy}


\fancyhead{} % clear all header fields
\fancyhead[RO]{Informe Experiencia 5: Modelacion y Control PID}
\fancyhead[LE]{\bfseries \nouppercase{\sectionname}}
\fancyfoot{} % clear all footer fields
\fancyfoot[CE,CO]{\thepage}

\renewcommand{\headrulewidth}{1.5pt}
\renewcommand{\footrulewidth}{0pt}

\renewcommand{\rmdefault}{phv} % Arial
\renewcommand{\sfdefault}{phv} % Arial
\parindent 0em
\author{blabla}
\title{blabalbla2}
\begin{document}
\maketitle
\tableofcontents
\listoffigures
\newpage
\setcounter{chapter}{1}

\begin{section}{Introducci�n} %hecho
El enfoque que se le da al uso de controladores en un curso de Control de Sistemas es 
m�s bien te�rico, si bien se introducen casos pr�cticos de la industria. En ese mismo sentido
se postula que la introducci�n de un controlador en un lazo cerrado de control aporta
con ceros, tal que eliminen posibles respuestas no estables de una determinada planta, o bien, introduzcan polos tipicos de un sistema de segundo orden asint�ticamente estables, pero de tal forma que estos sean \begin{bf}
dominantes\end{bf} en la respuesta final del sistema. A continuaci�n se realiza esta tarea de forma 
pr�ctica, usando reglas emp�ricas para asignar valores a los par�metros caracteristicos de �ste, lo que se conoce como sintonizaci�n del controlador.

\end{section}
\end{document}

There're more code lines, but I omitted them for obvious reasons. As you can see, the sections are very short. Ignore the � character.

I hope this is useful.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Fancy heading problem: section name to the left side

Post by gmedina »

You didn't specify the position of the marks, so I assumed that you want the section information to appear on the even pages of a two-sided document; take a look at the following example and feel free to adapt it according to your needs:

Code: Select all

\documentclass[letterpaper,12pt,twoside]{report}
\usepackage{fancyhdr}
\usepackage{lipsum}% just to generate filler text for the example
\pagestyle{fancy}

\renewcommand{\sectionmark}[1]{%
  \markboth{}{Secci\'on\ \thesection.\ #1}}

\fancyhf{} % clear all header/footer fields
\fancyhead[RO]{Informe Experiencia 5: Modelaci\'on y Control PID}
\fancyhead[LE]{\bfseries \nouppercase{\rightmark}}
\fancyfoot[C]{\thepage}

\renewcommand{\headrulewidth}{1.5pt}
\renewcommand{\footrulewidth}{0pt}
\setlength\headheight{15pt}

\begin{document}
\chapter{Test chapter one}
\lipsum[1-5]
\section{Test section one}
\lipsum[1-20]
\section{Test section two}
\lipsum[1-20]
\end{document}
Edit: I changed \renewcommand\headheight{15pt} to \setlength\headheight{15pt} in the code.
Last edited by gmedina on Mon May 17, 2010 5:27 am, edited 1 time in total.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
turbomac
Posts: 34
Joined: Sat Oct 10, 2009 9:38 pm

Re: Fancy heading problem

Post by turbomac »

WHat if the document has no chapters, just sections??
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Re: Fancy heading problem

Post by gmedina »

The same solution will work...(didn't you try it)?
1,1,2,3,5,8,13,21,34,55,89,144,233,...
turbomac
Posts: 34
Joined: Sat Oct 10, 2009 9:38 pm

Fancy heading problem: section name to the left side

Post by turbomac »

It gives an error:

Code: Select all

exp4.tex:95:Missing \endcsname inserted. \lipsum[1-5]
Thanks for the answers!
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Fancy heading problem: section name to the left side

Post by gmedina »

turbomac wrote:It gives an error:

Code: Select all

exp4.tex:95:Missing \endcsname inserted. \lipsum[1-5]
Thanks for the answers!
Saying just that is useless. What code exactly produces that error?

Edit: my guess is that you are using the lipsum package together with babel with the spanish option; this will produce errors since the spanish option deactivates, for example, the use of lower case roman numerals. To prevent the error, simply remove the lipsum package (it was used only to generate some filler text in my previous example) and its \lipsum command and use some "real" text instead.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
turbomac
Posts: 34
Joined: Sat Oct 10, 2009 9:38 pm

Re: Fancy heading problem

Post by turbomac »

I removed the lipsum package, but it doesn't work. The left heading side doesn't show the section name. :(

Thanks for the answers!
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Fancy heading problem: section name to the left side

Post by gmedina »

Again... we need a minimal working example of the odd behaviour mentioned. The reason for asking you the MWE is that my example code produces the desired result (as you can see in the attached PDF, generated using the code I provided before) so there must be something in your actual code that causes the problem; without the MWE we cannot provide effective help.
Attachments
c.pdf
(56.76 KiB) Downloaded 265 times
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply