[Tex/LaTex] Using a different font in overpic

captionsmemoiroverpic

I'm using the overpic package in the memoir class to include figures and superimpose text on them. Is there a simple way to tell overpic to use a different font than the main font of my text? (I still want the figure captions to be in the main font, though.)

Here's a MWE:

\documentclass[11pt,a4paper]{memoir}

\usepackage{fouriernc} % use the Arev font
\usepackage{overpic} % use the overpic package

% caption images outside the figure environment
\newfixedcaption{\figcaption}{figure} \captionnamefont{\normalfont} \captiontitlefont{\normalfont}

\begin{document}

This is the font of my main text.

\begin{center}
\begin{overpic}[width=0.5\textwidth]{./myfig.pdf}
\put(10, 10){This should be a different font}
\end{overpic}
\figcaption{This should be the same font as my main text.}
\end{center}

\end{document}

Best Answer

You could redefine \put to insert \sffamily (or whichever font selection) automatically by inserting the following in your document preamble:

\let\oldput\put
\def\put(#1,#2)#3{%
  \oldput(#1,#2){\sffamily #3}%
}

Here's a minimal example:

enter image description here

\documentclass[11pt,a4paper]{memoir}
\let\oldput\put
\def\put(#1,#2)#3{%
  \oldput(#1,#2){\sffamily #3}%
}
\usepackage{fouriernc} % use the Arev font
\usepackage{overpic} % use the overpic package

% caption images outside the figure environment
\newfixedcaption{\figcaption}{figure} \captionnamefont{\normalfont} \captiontitlefont{\normalfont}

\begin{document}

This is the font of my main text.

\begin{center}
\begin{overpic}[width=0.5\textwidth]{tiger.pdf}
\put(10, 10){This should be a different font}
\end{overpic}
\figcaption{This should be the same font as my main text.}
\end{center}

\end{document}