Here How to cut a section title in the header we learn how to use \StrLeft with the package titleps.
However, LaTeX outputs an error when there is a math expression in my header say,
\section{The set $\mathbb{A}$ }
This is linked to the second defect: \StrLeft breaks the title and generally it will output a single letter before the three dots. Like so,
the se...
Is it possible to count the words (including the maths expressions between $ $) instead of the letters so as to cut the title always after a full word ?
is it possible to do the same when the math is entered via a personal command which included a \ensuremath, like so,
\newcommand{\rr}{\ensuremath{\mathbb{R}}\xspace}

It would be helpful if you composed a fully compilable MWE including
\documentclassand the appropriate packages that reproduces the problem.While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem.
– Peter Grill Apr 21 '14 at 15:31