1

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?

regeirk
  • 111

1 Answers1

2

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}

enter image description here

egreg
  • 1,121,712