1

I am trying to insert figures in minipages in newcommands to get two images on a a5 paper. MWE:

\documentclass{article}
\usepackage{mwe}
\usepackage[a5paper, margin=5mm]{geometry}

\newcommand{\twoimages}[2]{
    \centering
    \begin{minipage}
        \begin{figure}
            \begin{minipage}[c]{\textwidth}
               \includegraphics[width=0.97\textwidth]{#1}
            \end{minipage}
            \noindent
            \begin{minipage}[c]{\textwidth}
               \includegraphics[width=0.97\textwidth]{#2}
            \end{minipage}
        \end{figure}
    \end{minipage}
}

\begin{document}
\twoimages{example-image-plain}{example-image-plain}
\end{document}

which results in

<to be read again>
                   \relax
l.21 ...{example-image-plain}{example-image-plain}

I cant spot the error. I got part of the code from How to use figure inside a minipage? and I already tried \DeclareRobustCommand, but no luck.

Can you help?

1 Answers1

1

I overthought it. Thank you @leandriis and https://tex.stackexchange.com/users/134574/phelype-oleinik

\documentclass{article}
\usepackage{mwe}
\usepackage[a5paper, margin=5mm]{geometry}

\newcommand{\twoimages}[2]{
    \centering
    \begin{minipage}[c]{\textwidth}
       \includegraphics[width=0.96\textwidth]{#1}
        \noindent
       \includegraphics[width=0.96\textwidth]{#2}
    \end{minipage}
}

\begin{document}
\twoimages{example-image-plain}{example-image-plain}
\end{document}
  • 1
    the minipage here is doing nothing, you can delete it, similarly the \noindent command. The \centering command will apply to the whole document, perhaps that is OK but if your actual document has following text it will be centred. – David Carlisle Aug 12 '19 at 18:51
  • Thank you, too! – PatrickBateman Aug 13 '19 at 19:47