I am trying to redefine \includegraphics to both auto-label the included figure and to restrict the maximum width. The auto-labeling is done by transforming the base filename to camelcase using the stringstrings package. This is what I have:
\usepackage{stringstrings}
\usepackage[export]{adjustbox}
\usepackage{graphicx}
\let\origincludegraphics=\includegraphics
\renewcommand{\includegraphics}[1]{
\makeatletter
\filename@parse{#1}
\convertchar[q]{\filename@base}{\textunderscore}{\blankspace}
\capitalizewords[q]{\thestring}
\noblanks[q]{\thestring}
\origincludegraphics[max width=\linewidth]{\thestring}
}
It fails with an
**undefined control sequence**
error; this seems to be coming from the file parsing commands, because this doesn't work:
\documentclass[11pt]{report}
\usepackage{amsmath}
\begin{document}
\newcommand\testcmd[1]{
\makeatletter
\filename@parse{#1}
\filename@base
\makeatother
}
\testcmd{path/to/stuff.png}
\end{document}
- why doesn't file parsing work inside a command?
- is there another way to achieve my goal of figure auto-labeling by a component of the path?
\makeatletter(and\makeatother) outside of the command. – Robert Nov 19 '13 at 06:24\convertchar[q]{\filename@base}{\textunderscore}{ ??? }. I tried\blankspace,\quad, and\~but none of them worked. – Sean Mackesey Nov 19 '13 at 06:52