Graphics 在LaTeX中,有没有办法将图形的文件名包含在标题中?

Graphics 在LaTeX中,有没有办法将图形的文件名包含在标题中?,graphics,latex,caption,Graphics,Latex,Caption,我有一个LaTeX文档,其中包含大量来自\includegraphics{bla.pdf}外部文件的图纸。这些图纸是在Inkscape中绘制的。这一切都很好。但是,有时很难跟踪所有图形及其源文件。因此,我正在寻找一种方法,将示例bla.pdf中的源文件名包含到标题中。作为一名乳胶专家,我还没有找到从标题中自动访问文件名字符串的方法。使用GoogleFoo也没有产生结果。是否存在引用文件名并将其包含在标题中的现有方法,如\caption{bla(\filename})的花式绘图?重新定义\incl

我有一个LaTeX文档,其中包含大量来自
\includegraphics{bla.pdf}
外部文件的图纸。这些图纸是在Inkscape中绘制的。这一切都很好。但是,有时很难跟踪所有图形及其源文件。因此,我正在寻找一种方法,将示例
bla.pdf
中的源文件名包含到标题中。作为一名乳胶专家,我还没有找到从标题中自动访问文件名字符串的方法。使用GoogleFoo也没有产生结果。是否存在引用文件名并将其包含在标题中的现有方法,如
\caption{bla(\filename}
)的花式绘图?

重新定义
\includegraphics
。对于没有参数的情况(宽度=3cm,比例=2或类似的东西),我们有

用途

\includegraphics{bla.pdf}
\caption{A fancy drawing of bla (\filename)}

您可以通过修补
\includegraphics
中嵌套调用的一部分来捕获映像文件名:

\documentclass{article}
\usepackage{graphicx,etoolbox}
\马克特莱特
\patchcmd{\Gin@setfile}% 
{\ProvidesFile}%
{\xdef\imgfilename{{#3}\ProvidesFile}%
{}{}% 
\Maketother
\开始{document}
\开始{图}
\定心
\includegraphics[width=.5\linewidth]{示例图像}
\标题{图像:\imgfilename}
\结束{图}
\结束{document}

\imgfilename
只有在使用后才会包含在
\includegraphics
中使用的文件名。

您知道吗?乳胶问题仍然在这里讨论,但您可能会在那里得到更好或更快的答案。如果您能给我们一个您目前正在做的小示例,我们可能会想出一个定制的解决方案。…如果我有参数呢?我在序言中还包含自定义命令的图像。
\includegraphics{bla.pdf}
\caption{A fancy drawing of bla (\filename)}
\documentclass{article}

\usepackage{graphicx,etoolbox}

\makeatletter
\patchcmd{\Gin@setfile}% <cmd>
  {\ProvidesFile}% <search>
  {\xdef\imgfilename{#3}\ProvidesFile}% <replace>
  {}{}% <success><failure>
\makeatother

\begin{document}

\begin{figure}
  \centering
  \includegraphics[width=.5\linewidth]{example-image}
  \caption{Image: \imgfilename}
\end{figure}

\end{document}