Print file name of figure below figure

  • Follow


Hello,

this is a follow-up to the thread ``Print file name of figure in 
margin'' started yesterday.

Now I'd like to output the file name below the inserted figure.  The 
min. example shows how I'm trying to do this, but what I get is the file 
name next to the figure, not below.

What I want:

-----------
|	  |
|         |
|         |
-----------
file name

What I get:
-----------
|	  |
|         |
|         |
-----------file name

What I do:

\documentclass{scrartcl}
\usepackage{graphicx}
\usepackage{marginnote}
\renewcommand*{\marginfont}{\tiny\sffamily}
\makeatletter
\let\old@Gin@setfile\Gin@setfile
\def\Gin@setfile#1#2#3{%
   \old@Gin@setfile{#1}{#2}{#3}%
   \begingroup
   \edef\@tempa{#3}%
% 
\expandafter\marginnote\expandafter{\expandafter\strip@prefix\meaning\@tempa}%
 
\expandafter\par\footnotesize\ttfamily\expandafter{\expandafter\strip@prefix\meaning\@tempa}%
   \endgroup
}
\makeatother
\begin{document}
\includegraphics[scale=0.6]{JT00025102B}
\end{document}

Thanks!
Markus
0
Reply Markus 3/3/2010 6:15:55 PM

On Wed, 03 Mar 2010 10:15:55 -0800, Markus Heller <hellerm2@gmail.com>
wrote:

>Hello,
>
>this is a follow-up to the thread ``Print file name of figure in 
>margin'' started yesterday.
>
>What I want:
>
>-----------
>|	  |
>|         |
>|         |
>-----------
>file name
>
>What I get:
>-----------
>|	  |
>|         |
>|         |
>-----------file name
>
>What I do:
>
>\documentclass{scrartcl}
>\usepackage{graphicx}
>\usepackage{marginnote}
>\renewcommand*{\marginfont}{\tiny\sffamily}
>\makeatletter
>\let\old@Gin@setfile\Gin@setfile
>\def\Gin@setfile#1#2#3{%
>   \old@Gin@setfile{#1}{#2}{#3}%
>   \begingroup
>   \edef\@tempa{#3}%
>% 
>\expandafter\marginnote\expandafter{\expandafter\strip@prefix\meaning\@tempa}%
> 
>\expandafter\par\footnotesize\ttfamily\expandafter{\expandafter\strip@prefix\meaning\@tempa}%
>   \endgroup
>}
>\makeatother

I'd omit the \marginnote command an symply save the filename:
def\Gin@setfile#1#2#3{%
   \old@Gin@setfile{#1}{#2}{#3}%
   \begingroup
     \edef\@tempa{#3}%
     \@onelevel@sanitize\@tempa
     \xdef\CurrentGraphicFileName{\@tempa}
   \endgroup
}

This leaves the filename in \CurrentGraphicFileName 
(with all its characters having \catcode 12), which 
I would then place below the graphic, perhaps in 
the caption:

  \caption{\texttt{\CurrentGraphicFileName}\\ Rest of caption}

>\begin{document}
>\includegraphics[scale=0.6]{JT00025102B}
>\end{document}

If you don't float these then maybe use a tabular to get
the name under the graphic:

  \begin{tabular}{c}
    \includegraphics[scale=0.6]{JT00025102B}\\
    \texttt{\CurrentGraphicsFileName}%
  %You might then wish to undefine it
    \global\let\CurrentGraphicsFileName\relax
  \end{tabular}

Caveat: not tested, although I have done things like this.

Dan
To reply by email, change LookInSig to luecking
0
Reply Dan 3/3/2010 9:56:20 PM


On 3/3/2010 1:56 PM, Dan Luecking wrote:
> On Wed, 03 Mar 2010 10:15:55 -0800, Markus Heller<hellerm2@gmail.com>
> wrote:
>
>> Hello,
>>
>> this is a follow-up to the thread ``Print file name of figure in
>> margin'' started yesterday.
>>
>> What I want:
>>
>> -----------
>> |	  |
>> |         |
>> |         |
>> -----------
>> file name
>>
>> What I get:
>> -----------
>> |	  |
>> |         |
>> |         |
>> -----------file name
>>
>> What I do:
>>
>> \documentclass{scrartcl}
>> \usepackage{graphicx}
>> \usepackage{marginnote}
>> \renewcommand*{\marginfont}{\tiny\sffamily}
>> \makeatletter
>> \let\old@Gin@setfile\Gin@setfile
>> \def\Gin@setfile#1#2#3{%
>>    \old@Gin@setfile{#1}{#2}{#3}%
>>    \begingroup
>>    \edef\@tempa{#3}%
>> %
>> \expandafter\marginnote\expandafter{\expandafter\strip@prefix\meaning\@tempa}%
>>
>> \expandafter\par\footnotesize\ttfamily\expandafter{\expandafter\strip@prefix\meaning\@tempa}%
>>    \endgroup
>> }
>> \makeatother
>
> I'd omit the \marginnote command an symply save the filename:
> def\Gin@setfile#1#2#3{%
>     \old@Gin@setfile{#1}{#2}{#3}%
>     \begingroup
>       \edef\@tempa{#3}%
>       \@onelevel@sanitize\@tempa
>       \xdef\CurrentGraphicFileName{\@tempa}
>     \endgroup
> }
>
> This leaves the filename in \CurrentGraphicFileName
> (with all its characters having \catcode 12), which
> I would then place below the graphic, perhaps in
> the caption:
>
>    \caption{\texttt{\CurrentGraphicFileName}\\ Rest of caption}
>
>> \begin{document}
>> \includegraphics[scale=0.6]{JT00025102B}
>> \end{document}
>
> If you don't float these then maybe use a tabular to get
> the name under the graphic:
>
>    \begin{tabular}{c}
>      \includegraphics[scale=0.6]{JT00025102B}\\
>      \texttt{\CurrentGraphicsFileName}%
>    %You might then wish to undefine it
>      \global\let\CurrentGraphicsFileName\relax
>    \end{tabular}
>
> Caveat: not tested, although I have done things like this.
>
> Dan
> To reply by email, change LookInSig to luecking

Dan,

thanks a lot, this works like a charm!

Cheers
Markus
0
Reply Markus 3/3/2010 11:26:37 PM

2 Replies
168 Views

(page loaded in 0.04 seconds)


Reply: