# Figcaps and special characters

I'm trying to use the figcaps package in an article to keep all figures at the end of the document. When I compile the following TeX code using pdflatex I get the following error message:

! Package inputenc Error: Unicode char \u8:�oS not set up for use with LaTeX.


Although it says to an inputenc error, when I try without using the figcaps, everything works smoothly.

Below is an example to illustrate my issue. Please make sure you have an image file named image_file. I have tried this sample a couple of times, and the error does not always raise, but in the PDF the captions look awful.

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage[printfigures]{figcaps}

\begin{document}

\begin{figure}
\includegraphics[width=1.\textwidth]{image_file}
\caption{Location of the Southeast Brazilian Bight~(SBB) and detail of the São Sebastião Channel.}
\label{fig:Map}
\end{figure}

\end{document}


The error raises because I use a special character in the figure caption, in this case ã and I suppose a similar error would rise using any of the following characters: ñ, â, Ü, ...

I am aware that a workaround would be to use escaped codes such as \~a, for example.

However, I usually find it annoying to use these escaped codes and try to avoid them. Is there any other option?

• egregs answer in utf8x vs. utf8 (inputenc) shines a bit of light on the progress of this as of April 2016. I have not yet updated to TexLive 2016, so I cannot see if these codes have been updated yet. you could solve this by using utf8x, but it should be avoided, according to egreg, or God, as I like to call him. – Runar Jun 23 '16 at 20:21
• Thank you for your kind reply. The same happens with utf8x. – regeirk Jun 23 '16 at 20:29
• Works fine here, with utf8x. – Runar Jun 23 '16 at 20:30
• Compiles with utf8x but characters replaced with "[Pleaseinsertintopreamble]". Using inputenc.sty 2015/03/17 v1.2c and utf8x.def 2004/10/17 – Christoph Frings Jun 23 '16 at 20:46
• Apparently it's figcaps's fault. – egreg Jun 23 '16 at 22:15

## 1 Answer

The problem is similar to the one in Is it possible to get the package listofsymbols to recognize the \cdots command?. The figcaps package uses \immediate\write and multibyte UTF-8 characters don't survive it. Also the solution is similar

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage[printfigures]{figcaps}
\usepackage{xpatch}

\makeatletter
% get a copy of \protected@write
\let\protected@iwrite\protected@write
% patch the copy to add \immediate
\xpatchcmd{\protected@iwrite}{\write}{\immediate\write}{}{}
% patch \FC@writefile to use \protected@iwrite instead of \immediate\write
\long\def\FC@writefile#1#2{\@ifundefined{tf@#1}{}{%
\expandafter\protected@iwrite\csname tf@#1\endcsname{}{#2}}}
\makeatother

\begin{document}

\begin{figure}
\includegraphics[width=1.\textwidth]{example-image}

\caption{Location of the Southeast Brazilian Bight~(SBB) and detail of the São Sebastião Channel.}
\label{fig:Map}
\end{figure}

\end{document}