我想在同一行中放置两个小页面。其中一个带有图片。编译时出现错误。您能更正代码吗?谢谢。
\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}
\linespread{1.5}
\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}
\addtocounter{copynum}{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}
答案1
您的文档中有很多多余的空白。有些是无害的,有些则不是。
s之间的换行minipage
会导致它们被设置在不同的段落中。如果您希望它们彼此相邻,则它们之间不能有换行符。在下面的代码中,我删除了很多在您的示例中似乎不必要的内容,但更重要的是,删除了minipage
我添加的 s之间的内容\hspace*{\fill}
(\hspace{<any dim/fill>}
效果一样好)。
\documentclass[addpoints]{exam}
\usepackage[italian]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\linespread{1.5}
\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}
\addtocounter{copynum}{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}
我不确定您是否真的希望width
的 为\includegraphics
。0.10\textwidth
这将把它设置为调用 的0.10
的宽度。minipage
\includegraphics
此外,你呼吁漂浮在 中minipage
。浮点数不应该这样使用。它们是浮点数,部分原因是用户放弃了对它们的控制,并将它们置于浮动状态,以便 LaTeX 决定最佳位置(因此会出现许多与浮动相关的麻烦)。如果您真的想将其视为将出现在浮动表格等中的浮动,那么此引用中还有许多其他与该主题相关的问题。这不是我的强项,因为在我的工作中,我从不使用浮动。
如果您要强制图片的大小,那么为什么不将的宽度设置为该minipage
尺寸,然后\includegraphics
按如下方式调用:
\begin{minipage}[t][][b]{6cm}
\centering
\includegraphics[draft,width=1.00\textwidth]{my_pic.pdf}
\end{minipage}%
结果是
如果你对图片的水平对齐不满意,你可以使用\raisebox{<raise value}[<height>][<depth>]{<box containing picture>}
如下方法
\begin{minipage}[t][][b]{6cm}
\centering
\raisebox{20pt}[\dimexpr\height-20pt][20pt]{\includegraphics[draft,width=1.00\textwidth]{my_pic.pdf}}
\end{minipage}%
导致