Skip to content

Instantly share code, notes, and snippets.

@ejmg
Created October 19, 2017 23:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ejmg/213e8b95f28b4dda29cce2c426efc926 to your computer and use it in GitHub Desktop.
Save ejmg/213e8b95f28b4dda29cce2c426efc926 to your computer and use it in GitHub Desktop.
how to put two figures, side by side proportionally, in a latex file
\usepackage{multirow,array}
\usepackage{floatrow}
% in combination with floatrow for properly adjusted figures, placeins ensures said figures appear
% where they are declared within the latex code, i.e. in subsection Part I of this paper. For proper
% usage with subsections, MUST use \FloatBarrier command after done with a figure
\usepackage[section]{placeins}
% ensures captions are properly centered under their respective figures
\usepackage[justification=centering]{caption}
% special command for table captions
\newfloatcommand{capbtabbox}{table}[][\FBwidth]
\begin{document}
\begin{figure}
\begin{floatrow}
\ffigbox{%
\includegraphics[width=0.75\linewidth]{supply-demand-basic.png}
}{%
\caption[]{Classic supply \& demand diagram}%
}
\end{floatrow}
\end{figure}
\begin{figure}
\begin{floatrow}
\capbtabbox{%
\setlength{\extrarowheight}{2pt}
\begin{tabular}{cc|c|c|}
& \multicolumn{1}{c}{} & \multicolumn{2}{c}{Prisoner $Y$}\\
& \multicolumn{1}{c}{} & \multicolumn{1}{c}{$Silent$} & \multicolumn{1}{c}{$Snitch$} \\\cline{3-4}
\multirow{2}*{Prisoner $X$} & $Silent$ & $(1.0, 1.0)$ & $(0.0, 0.75)$ \\\cline{3-4}
& $Snitch$ & $(0.75, 0.0)$ & $(0.25, 0.25)$ \\\cline{3-4}
\vspace{20.0 pt} % if you want to shift the table
\end{tabular}
}{%
\caption{Classic single iteration Prisoner's Dilemma payoff matrix}%
}
\end{floatrow}
\end{figure}
\FloatBarrier
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment