调整边距中的图形或图像

调整边距中的图形或图像

假设我想将数字放在边距中。我有以下代码,其结果为:

在此处输入图片描述

\documentclass[11pt,twoside,openany]{book}

\usepackage{amsmath,amssymb}
\usepackage{lipsum}
\usepackage[demo]{graphicx}
\usepackage{multicol,calc,etoolbox}
\usepackage{marginnote}
\usepackage{caption}
%-------------------------------------------------------------------------------
\usepackage[centering,marginparwidth=2in]{geometry}
\evensidemargin 1.5in
\oddsidemargin 1.5in
\setlength{\textwidth}{5.5in}
%-------------------------------------------------------------------------------

\newenvironment{exotmp}{%
  \begin{list}{}{%
  \setlength{\leftmargin}{-1.5in}%
  \setlength{\rightmargin}{0pt}%
  \setlength{\parfillskip}{0pt plus 2fil}
  }% 
  \item\mbox{}\ignorespaces%
}
{\end{list}\ignorespacesafterend}

\newcommand\MarginFig[4][width=\marginparwidth]{%
\marginpar{\includegraphics[#1]{#2}
\captionof{figure}{#3}
\label{#4}}
}
%To put all marginnotes on the left side only the patch below is implemented
\makeatletter
\patchcmd{\@mn@margintest}{\@tempswafalse}{\@tempswatrue}{}{}
\patchcmd{\@mn@margintest}{\@tempswafalse}{\@tempswatrue}{}{}
\reversemarginpar
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\chapter{Introduction to Problem Solving}
\lipsum[2]
\section{The Problem-Solving Process and Strategies}
\lipsum[4-7]
\section{Three Additional Strategies}
\lipsum[5-12]
\begin{exotmp}
\setlength{\columnsep}{0.5cm}
\begin{multicols}{2}
\lipsum[2-9]
\end{multicols}
\end{exotmp}
\MarginFig{pencil}{description for figure one}{fig:test1}
\lipsum[1-3]
\MarginFig{pencil}{description for figure one}{fig:test2}
\end{document}

是什么原因导致图形无法正确显示以及如何修复。我读过这篇文章,如何使所有图形浮动在双面文档的外边距上?,但未能成功修复该问题。

PS:另外请注意,如果上述代码存在任何不一致或 LaTeXing 不好的地方,我会尝试进行修复。

答案1

发现了我的错误:

\marginpar不是

\newcommand\MarginFig[4][width=\marginparwidth]{%
\marginpar{\includegraphics[#1]{#2}
\captionof{figure}{#3}
\label{#4}}
}

它应该是:

\newcommand\MarginFig[4][width=\marginparwidth]{%
\marginnote{\includegraphics[#1]{#2}
\captionof{figure}{#3}
\label{#4}}
}

这只是我的一个简单错误,当然,多亏了@PeterGrill 的烦人问题,我才得以解决我的问题。:-)

相关内容