French accents in \hl from soul package

I'd like to use the \hl command from the soul package in a French text. However, it does not work whenever the part to highlight contains French accents (e.g.: \hl{é}).

I could use \'e instead of é (\hl{\'e}) but it would be quite long to substitute all the accents just in case I will have to highlight them later (and there are several accents in French : é, è, ù, à, ...).

Do you know whether it's possible to make \hl works with accents without substituing all the accents?

Here is an example file:

\documentclass[15pt , a4paper]{article}

\usepackage[french]{babel}
\usepackage[utf8] {inputenc}
\usepackage{soul}
\usepackage{color}

\definecolor{y}{RGB}{245, 255, 189}
\sethlcolor{y}

\begin{document}
\hl{\'e} % works
%\hl{é} % doesn't work
\end{document}
-
What do you mean by "doesn't work"? Be more specific. – Jubobs Feb 13 '14 at 10:44
It returns : "ERROR: Argument of \UTFviii@two@octets has an extra }." With the package soulutf8 it works. – Zach Feb 14 '14 at 15:28

For UTF-8 input, use soulutf8; don't forget fontenc!

\documentclass[a4paper]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{soulutf8}
\usepackage{color}

\definecolor{y}{RGB}{245, 255, 189}
\sethlcolor{y}

\begin{document}

\hl{\'e}
\hl{é}

\end{document}

There is no 15pt option for article.

-
Perfect, thanks ! – Zach Feb 14 '14 at 15:27
+1 for this so unimaginable solution! – Sigur Jun 6 '14 at 13:27

The soul package has its limitations. This one seems to be one of them.

You can let it work by putting accented characters in a \mbox:

\documentclass[a4paper]{article}

\usepackage[french]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{soul}
\usepackage{color}

\definecolor{y}{RGB}{245, 255, 189}
\sethlcolor{y}

\begin{document}
\hl{\'e} % works
\hl{\mbox{é}} % works as well
\end{document}

Output:

Otherwise you have to use XeLaTeX

\documentclass[a4paper]{article}

\usepackage[french]{babel}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{soul}
\usepackage{color}

\definecolor{y}{RGB}{245, 255, 189}
\sethlcolor{y}

\begin{document}
\hl{\'e} % works
\hl{é} % works as well
\end{document}
-
I want to mention that the mbox trick also works for other delicate commands, such as \ce{...}. – Vincent Fourmond Jul 17 '15 at 12:13
Oh, yes, it also works for \cite ! – Vincent Fourmond Jul 17 '15 at 13:30
@VincentFourmond Happy that my answer helped you! – karlkoeller Jul 17 '15 at 15:19

\documentclass[12pt , a4paper]{article}
\usepackage{fontspec}
\usepackage[french]{babel}
%\usepackage[utf8] {inputenc}
\usepackage{soul}
\usepackage{color}

\definecolor{y}{RGB}{245, 255, 19}
\sethlcolor{y}

\begin{document}
\hl{\'e} % works
\hl{é} % works
\end{document}
-