Version 2.4a of fontspec no longer loads the package fixltx2e, cf. fontspec's README file:
Change history
--------------
- v2.4a (2014/06/21)
* No longer load fixltx2e.sty -- this package should really be loaded before \documentclass.
The problem occurs when the fragile command \raisebox is used in a section heading. fixltx2e makes the command robust, as explained in its documentation:
%\begin{verbatim}
% >Number: 3816
% >Category: latex
% >Synopsis: Argument of \@sect has an extra }.
% >Arrival-Date: Sat Oct 22 23:11:01 +0200 2005
% >Originator: susi@uriah.heep.sax.de (Susanne Wunsch)
%
% Use of a \raisebox in \section{} produces the error message
% mentioned in the subject.
%
% PR latex/1738 descriped a similar problem, which has been solved
% 10 years ago. Protecting the \raisebox with \protect solved my
% problem as well, but wouldn't it make sense to have a similar fix
% as in the PR?
%
% It is particulary confusing, that an unprotected \raisebox in a
% \section*-environment works fine, while in a \section-environment
% produces error.
%\end{verbatim}
%
% While not technically a bug, in this day and age there are few
% reasons why commands taking optional arguments should not be robust.
%
% \subsubsection{Notes on the implementation strategy}
%
% Rather than changing the kernel macros to be robust, we have decided
% to add the macro \DescribeMacro{\MakeRobust}|\MakeRobust| in
% \Lpack{fixltx2e} so that users can easily turn fragile macros into
% robust ones. A macro |\foo| is made robust by doing the simple
% |\MakeRobust{\foo}|. \Lpack{fixltx2e} makes the following kernel
% macros robust: |\(|, |\)|, |\[|, |\]|, |\makebox|, |\savebox|,
% |\framebox|, |\parbox|, |\rule| and |\raisebox|.
Loading fixltx2e takes care of the problem:
\documentclass{article}
\usepackage{fixltx2e,fontspec}
\setmainfont{Linux Libertine O}
\newcommand{\foobar}{\textit{\kern-.2em\raisebox{.1ex}{\char"02CB}\kern.2em\kern-.25em}}
\begin{document}
Wo{\foobar}rd
\section{Wo{\foobar}rd}
\end{document}
Alternatively, use \DeclareRobustCommand when the macro contains a fragile command like \raisebox:
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Linux Libertine O}
\DeclareRobustCommand{\foobar}{\textit{\kern-.2em\raisebox{.1ex}{\char"02CB}\kern.2em\kern-.25em}}
\begin{document}
Wo{\foobar}rd
\section{Wo{\foobar}rd}
\end{document}
Cf. also the LaTeX wiki book and What is the difference between Fragile and Robust commands?.
fixltx2eneeded for in this case, and how do I define the command in a "robust" way? Also note that the command works in regular text, just not in a section heading. – Sverre Sep 17 '14 at 13:19fixltx2eare the bullet points at http://www.ctan.org/pkg/fixltx2e, which don't really explain what the problem is withraiseboxin section headings. – Sverre Sep 17 '14 at 13:51