发布时间:2010-01-18 16:56:28
文章类别:插图技巧
原文地址:http://blog.sina.com.cn/s/blog_5e16f1770100gwkl.html

QQ群:91940767/145316219/141877998/80300084/194770436
淘宝店:http://latexstudio.taobao.com
技巧续篇:http://latexstudio.net/
常见数学公式问题集下载

要将图形与标题均置于盒子中,也许有人想当然的以为把 \caption 命令也放到 \fbox 命中就可以了。然而,由于 \caption 命令 只能在段落模式中使用,而 \fbox 命令中的内容是在 LR 模式中被处理 的, 所以这样做是不能达到目的的。 因为小页环境的内容和 \parbox 命令都使在段落模式中处理,所以将 \fbox 命令的内容放到小页环境或 \parbox 命令中,就可以把 \caption 包含在 \fbox 中。由于小页环境和 \parbox 命令 都必须给出它们的宽度,故没有直接的办法让 \fbox 和图形及其标题一样 宽。 例如下列命令:
\begin{figure} 
  \centering 
  \fbox{ 
    \begin{minipage}{4 in} 
      \centering 
      \includegraphics[totalheight=2in]{pend.eps} 
      \caption{Box Around Figure Graphic and Caption} 
      \label{fig:boxed_figure} 
    \end{minipage} } 
\end{figure}
得到图,其中图形与标题都置于盒子中。

% latex2html id marker 6353 \fbox{ \begin{minipage}{4 in} \centering \i... ...]{pend.eps} \caption{Box Around Figure Graphic and Caption} \end{minipage} }
一般通过不断的尝试修改来确定小页环境的宽度从而使得盒子能够恰好 围住图形和标题。下面的这些方法可以避免枯燥麻烦的尝试修改。
  1. 选择一个确定的小页的宽度,使得图形的宽度与其相同。
    
          \includegraphics[width=\textwidth]{pend.eps}
    
    
  2. 当指定图形的高度时,适当的小页的宽度可以通过把图形放到一个 盒子中,然后计算盒子的宽度来得到。
          \newsavebox{\mybox} 
          \newlength{\mylength} 
          \sbox{\mybox}{\includegraphics[height=3in]{file.eps}} 
          \settowidth{\mylength}{\usebox{\mybox}} 
          \begin{figure}
            \centering 
            \fbox{ 
              \begin{minipage}{\mylength} 
                \centering 
                \usebox{\mybox} 
                \caption{Box Around Figure Graphic and Caption} 
                \label{fig:boxed_figure} 
              \end{minipage} } 
          \end{figure}
    
  3. 为保证标题只有一行,可以使用 \settowidth 命令来估计标题 的宽度并将其作为小页的宽度。
          \newlength{\mylength} 
          \settowidth{\mylength}%
            {Figure XX: Box Around Figure Graphic and Caption} 
          \fbox{ \begin{minipage}{\mylength} 
            ...
    


点赞(1)

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部