# problem with minipages

I would like to have two minipages in the same row. One of them has a picture. There is an error in the compilation. Can you correct the code? Thank you.

\documentclass[addpoints]{exam}

\usepackage[italian]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{anysize}
\usepackage{graphicx}
\usepackage{float}
\usepackage{etoolbox}
\usepackage{amsbsy}
\usepackage{amsmath}
\usepackage{pbox}

\usepackage{cancel}
\usepackage{tabularx}

%
\usepackage{subfig}
\usepackage{xcolor}

\frenchspacing

\newcommand{\abs}[1]{\lvert#1\rvert}

\usepackage{floatflt,epsfig}

\usepackage{multicol}

%\usepackage[a4paper,top=1.5cm,bottom=1.5cm,left=1.5cm,right=1.5cm]{geometry}

\usepackage[a4paper,top=0.9cm,bottom=0.9cm,left=1.2cm,right=1.2cm]{geometry}

\usepackage{enumerate}

%   \renewcommand{\rmdefault}{phv}
%   %\usepackage{mathpple}
%   %\usepackage{palatino}
%
%   \usepackage{lxfonts}
%
%   \usepackage{multicol}

\makeatletter
\newcommand*{\ExamResetAfterFirstRun}{%
\renewcommand*{\PgInfo@write}[1]{}%
\renewcommand*{\label}[1]{\@bsphack\@esphack}%
}
\makeatother

\pointpoints{Punto}{Punti}
\bonuspointpoints{punto (bonus)}{punti (bonus)}

\usepackage{pstricks}

\usepackage{tikz}
\usetikzlibrary{3d}

\begin{document}

\large

\newcounter{copynum} % copy number, to be printed in the footer
\newcounter{NumCopy} % how many copies do we want?
\setcounter{NumCopy}{1} % we want 3
\whiledo{\thecopynum<\theNumCopy}{%
\setcounter{page}{1}
\setcounter{question}{1}
\setcounter{part}{1}
\setcounter{numquestions}{0}
\setcounter{numpoints}{0}
\setcounter{numbonuspoints}{0}
\setcounter{numparts}{0}
\setcounter{numsubparts}{0}
\setcounter{numsubsubparts}{0}
\ifnum\value{copynum}>1 %
\ExamResetAfterFirstRun
\fi

\begin{questions}

\question[4] question:

\begin{minipage}[t][][b] {6cm}
\begin{enumerate}
\item subquestion
%\item $\vec{a} - \vec{b}$
\item subquestion
%\item $2\vec{a}$
\end{enumerate}
\end{minipage}%

\begin{minipage}[t][][b] {6cm}
\begin{figure}[!h]
\centering
\captionsetup{font={small,it}, labelfont=bf}
{\includegraphics[width=.10\textwidth]{vettori_orizzontali_recupero_v01.pdf}\label{vettore_02}}
\label{fig_a_grav}
%subfig}
\end{figure}
\end{minipage}%

\end{questions}

}

\end{document}


• Does it help? tex.stackexchange.com/a/165694/1952 – Ignasi Feb 28 '16 at 17:48
• thank you. but i can't modify the size of the pic :( – ryuk Feb 28 '16 at 17:55
• What do you mean you "can't"? That you don't know how? That it's not allowed? That it must be the size you're choosing there? – A.Ellett Feb 28 '16 at 17:59

You've got a lot of extra white space in your document. Some of it is innocuous, some of it isn't.

The line skip between the minipages is going to cause them to be set in different paragraphs. If you want them adjacent to each other, then you cannot have a line break between them. In my code below, I've removed a lot of what seems unnecessary to your example, but more importantly, between the minipages I've added \hspace*{\fill} (\hspace{<any dim/fill>} could have worked just as well).

\documentclass[addpoints]{exam}

\usepackage[italian]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{graphicx}

\frenchspacing
\usepackage[a4paper,top=0.9cm,bottom=0.9cm,left=1.2cm,right=1.2cm]{geometry}
\usepackage{enumerate}

\makeatletter
\newcommand*{\ExamResetAfterFirstRun}{%
\renewcommand*{\PgInfo@write}[1]{}%
\renewcommand*{\label}[1]{\@bsphack\@esphack}%
}
\makeatother

\pointpoints{Punto}{Punti}
\bonuspointpoints{punto (bonus)}{punti (bonus)}

\begin{document}
\large

\newcounter{copynum} % copy number, to be printed in the footer
\newcounter{NumCopy} % how many copies do we want?
\setcounter{NumCopy}{3} % we want 3
\whiledo{\thecopynum<\theNumCopy}{%
\setcounter{page}{1}
\setcounter{question}{1}
\setcounter{part}{1}
\setcounter{numquestions}{0}
\setcounter{numpoints}{0}
\setcounter{numbonuspoints}{0}
\setcounter{numparts}{0}
\setcounter{numsubparts}{0}
\setcounter{numsubsubparts}{0}
\ifnum\value{copynum}>1 %
\ExamResetAfterFirstRun
\fi
\begin{questions}
\question[4] question:

\begin{minipage}[t][][b]{6cm}
\begin{enumerate}
\item subquestion
%\item $\vec{a} - \vec{b}$
\item subquestion
%\item $2\vec{a}$
\end{enumerate}
\end{minipage}%
%% -- line break?? --
\hspace*{\fill}%%
\begin{minipage}[t][][b]{6cm}
\centering
\includegraphics[draft,width=0.10\textwidth]{my_pic.pdf}
\end{minipage}%
\end{questions}%%
}

\end{document}


I'm not sure you really want the width of the \includegraphics to be 0.10\textwidth. That's going to set it to 0.10 of the width of the minipage that the \includegraphics is called from.

Additionally, you're calling for a float from within a minipage. Floats aren't meant to be used this way. They're floats, in part, because the user has relinquished hold of them and sets them afloat for LaTeX to decide the optimal location (hence so many headaches that crop up with regard to floats). If you really want to treat this as a float that will show up in a table of floats etc., then there are many of other questions on this cite related to that topic. It is not my forte because in my work, I never use floats in my work.

If you're going to force the size of the picture, then why not set the width of the minipage to that size then call the \includegraphics as follows:

       \begin{minipage}[t][][b]{6cm}
\centering
\includegraphics[draft,width=1.00\textwidth]{my_pic.pdf}
\end{minipage}%


which results in

If you're not happy about the horizontal alignment of the picture, you can use \raisebox{<raise value}[<height>][<depth>]{<box containing picture>} as in

       \begin{minipage}[t][][b]{6cm}
\centering
\raisebox{20pt}[\dimexpr\height-20pt][20pt]{\includegraphics[draft,width=1.00\textwidth]{my_pic.pdf}}
\end{minipage}%


resulting in