0

Is it possible to code a new command, which use the path of 2 figures with \includegraphics, and positions them next to each other and generates a box around them? One figure should be titled as "False" and the other one as "Correct". I'm using these to improve my script at university and would like to automate this procedure.

3

There are many ways of doing it, and many ways to interpret your specification. The following solution should at least help to say more precisely what you want to have differently.

enter image description here

\documentclass{article}
\usepackage{graphicx}
\newcommand\twofigures[2]{%
  \fbox{%
    \begin{tabular}{@{}cc@{}}
      \includegraphics[width=0.45\textwidth]{#1}
      & \includegraphics[width=0.45\textwidth]{#2}\\
      False & Correct
    \end{tabular}%
  }%
}
\begin{document}
\twofigures{example-image-a}{example-image-b}
\end{document}
2

I'd like to use minipage environment to handle this.

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\newcommand{\TFfigures}[2]{
    \fbox{
        \begin{minipage}{.45\textwidth}
        \includegraphics[width=\textwidth]{#1}
        \captionof{figure}{False}
    \end{minipage}
    \begin{minipage}{.45\textwidth}
        \includegraphics[width=\textwidth]{#2}
        \captionof{figure}{Correct}
    \end{minipage}
    }
}
\begin{document}
    \TFfigures{example-image-a}{example-image-b}
\end{document}

which will give enter image description here

If you don't want the "Figure 1", we can have a small change: use \captionof* instead of \captionof:

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\newcommand{\TFfigures}[2]{
    \fbox{
        \begin{minipage}{.45\textwidth}
        \includegraphics[width=\textwidth]{#1}
        \captionof*{figure}{False}
    \end{minipage}
    \begin{minipage}{.45\textwidth}
        \includegraphics[width=\textwidth]{#2}
        \captionof*{figure}{Correct}
    \end{minipage}
    }
}
\begin{document}
    \TFfigures{example-image-a}{example-image-b}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.