7

I'd like to include the section name in the header WITHOUT the section number.

The only instructions I could find on how to do this said to add this:

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}

...but when I added that, the section name never changed at all -- the header just displayed "Contents" for the whole document.

Thoughts?

I'm using Emacs org-mode to generate LaTeX. Here's what the template looks like.

\documentclass[12pt]{article}
\usepackage[hyperref,x11names]{xcolor}
\usepackage{float}
\usepackage[breaklinks=true,linktocpage,pdftitle={\@title},pdfauthor={\@author},xetex]{hyperref}
\usepackage{algorithm}
\usepackage{amsmath}
\usepackage{ifxetex}
\ifxetex
  \usepackage{fontspec,xltxtra,xunicode}
  \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
  \setromanfont{Adobe Garamond Pro}
  \setsansfont{Arial}
  \setmonofont{Courier}
\else
  \usepackage[mathletters]{ucs}
  \usepackage[utf8x]{inputenc}
\fi
\usepackage{microtype}
\usepackage{url}
\usepackage{graphicx}
\hypersetup{ colorlinks, citecolor=SteelBlue4,filecolor=SteelBlue4,linkcolor=SteelBlue4,urlcolor=SteelBlue4}
\makeatletter
\def\maketitle{
    {\fontsize{50}{60}\selectfont \textbf{\@title}\par}
    {\Huge {\textit{\@author}\par}}
    {\Large \@date\par}
   \end{raggedright}
  \null
  \cleardoublepage
}

\usepackage{paralist}
\let\itemize\compactitem
    \let\description\compactdesc
    \let\enumerate\compactenum  
    \let\description\compactdesc
    \usepackage{fancyhdr}
    \pagestyle{fancy}
    \pagenumbering{arabic}
    \renewcommand{\sectionmark}[1]{\markright{#1}}
    \lhead{\href{mailto:[email protected]}{Peter Salazar}}
    \chead{}
    \rhead{{\@title}: {\nouppercase{\leftmark}}}
    \lfoot{}
    \cfoot{\thepage}
    \rfoot{}
    \usepackage{listings}
    \lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
    \setlength{\parindent}{0pt}
    \setlength{\parskip}{12pt plus 2pt minus 1pt}
    \usepackage{fancyvrb}
    \usepackage{enumerate}
    \usepackage{ctable}
    \setlength{\paperwidth}{8.5in}
    \setlength{\paperheight}{11in}
     \usepackage[margin=1.5in,hmargin=1.5in,vmargin=1.5in]{geometry}
      \tolerance=1000
    \usepackage{tocloft}
    \renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
    \usepackage[normalem]{ulem}
    \newcommand{\textsubscr}[1]{\ensuremath{_{\scriptsize\textrm{#1}}}}

          [NO-DEFAULT-PACKAGES]
          [NO-PACKAGES]"
         ("\\section{%s}" . "\\section*{%s}")
         ("\\subsection{%s}" . "\\subsection*{%s}")
         ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
         ("\\paragraph{%s}" . "\\paragraph*{%s}")
         ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1
  • 4
    Make a small but complete example that demonstrates your problem so that we don't have to guess what packages and commands you are using. You can add pages with \newpage abc \newpage .... Mar 2, 2012 at 9:28

1 Answer 1

1

Your file is neither minimal nor complete. Cutting it down, this seems to work:

\documentclass[12pt]{article}
\usepackage[hyperref,x11names]{xcolor}

\title{Fake Title}
\author{Me}
\date{\today}

\makeatletter
\newcommand{\mytitle}{\@title}
\makeatother

\usepackage{fancyhdr}
\pagestyle{fancy}

% \renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markboth{#1}{}}
\lhead{\href{mailto:[email protected]}{Peter Salazar}}
\chead{}
\rhead{{\mytitle}: {\nouppercase{\leftmark}}}
\lfoot{}
\cfoot{\thepage}
\rfoot{}

\usepackage{hyperref} 
\hypersetup{colorlinks}

\begin{document}

\section{First}
a \newpage b \newpage c \newpage
\section{Second}
a \newpage b \newpage c \newpage
\section{Third}
a \newpage b \newpage c \newpage

\end{document}

One of the problems is that you are using a lot of \@<something> commands, which need to dealt with more carefully than normal macros (unless you externalize the set-up by putting it all in a .sty file of your own).

Anyway, here we have a section name in the header without a number.

Note, also, that hyperref should be one the last packages you load in any .tex file.

You must log in to answer this question.

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