I redefine my headers as in the following MWE:
\documentclass[12pt]{article}
\usepackage{xstring}
\usepackage{fancyhdr}
\fancypagestyle{monstyle}{%
\fancyhf{} % remove everything
\renewcommand{\headrule}{\rule[1.5ex]{\headwidth}{1pt}}
\lhead{%
\leftmark%
}
}
\begin{document}
\pagestyle{monstyle}
\section{le tres tres long titre qui prend trop de place sur la ligne}
\end{document}
The section title could be very long, like in my MWE, and i want to cut it at a fixed length (say 15 letters). My attempt is to use the command \StrLeft from the package xstring : I replace the line
\leftmark%
by
\StrLeft{\leftmark}{15}...%
But i get compilation errors which i do not understand:
Argument of \@iiparbox has an extra }.
EDIT I try to use Mico's solution, but i encounter now a problem with the TOC :
\documentclass[12pt]{article}
\usepackage{xstring}
\usepackage{fancyhdr}
\usepackage{blindtext}
%% Redefine the short title
\let\origsection\section %
\renewcommand{\section}[1]{%
\def\ShortSecName{\StrLeft{#1}{10}...}
\origsection[\protect\ShortSecName]{#1}%
}
\begin{document}
\tableofcontents
\section{mon titre tres long tres tres long}
\blindtext\blindtext\blindtext
\section{mon titre tres long tres tres long}
\blindtext\blindtext\blindtext
\end{document}
I get the error :
! LaTeX Error: Something's wrong--perhaps a missing \item.
If i remove \tableofcontents then it compiles.


\sectionhas an optional argument:\section[Short Title]{Long title which is long}The short version is what appears in headers, ToC etc. – Seamus Jan 16 '12 at 16:37