1

I have a custom section frame defined for my presentations. I'd like to load an image with the name of the section title. Problem is that LaTeX usually fails to load image if their names contain spaces. So I'm looking for a solution to replace the spaces (and by chance other special chars too) when passing \insertsection as parameter to \includegraphics.

here is a (not) working minimal example:

\documentclass{beamer}
\usetheme{default}
\usepackage{inputenc}
\setbeamertemplate{section page}{{
    \begin{frame}{\insertsectionhead}
        \begin{columns}
            \begin{column}{0.65\textwidth}                 
                 this should load an image with name
                  \texttt{some-section-with-spaces.png}
                 in the on the right of this text (if that exists...)
            \end{column}
            \begin{column}{0.45\textwidth}% 
                \includegraphics[width=0.7\linewidth]{%
                %% how to  replace spaces with minus or underscore here
                    \insertsection%
                }
            \end{column}
        \end{columns}
    \end{frame}
}}
\AtBeginSection{
  \sectionpage
}
\begin{document}
  \section{some section with spaces in name}
\end{document}
TeXnician
  • 33,589

1 Answers1

1

Approach 1

A simple workaround could be to use the section number to name the images:

\documentclass{beamer}
%\usetheme{default}
\usepackage{inputenc}
\setbeamertemplate{section page}{
    \begin{frame}{\insertsectionhead}
        \begin{columns}
            \begin{column}{0.65\textwidth}                 
                 this should load an image with name
                  \texttt{some-section-with-spaces.png}
                 in the on the right of this text (if that exists...)
            \end{column}
            \begin{column}{0.45\textwidth}% 
                \includegraphics[width=0.7\linewidth]{\thesection}
            \end{column}
        \end{columns}
    \end{frame}
}

\AtBeginSection{
  \sectionpage
}

\begin{document}
  \section{some section with spaces in name}

  \section{title}
\end{document}

Approach 2

If you want to stick to your original plan and use spaces in file names, then the grf­file package could help.