latex: 在article文档环境(multicols)中, 使用begin{figure}无法显示的问题
2015-11-11 16:20
531 查看
参考:Image not showing up when using figure environment,multicols宏包插入图片丢失,怎么办?
问题描述:在article环境下,使用begin{figure}无法显示图片,例子如下:
问题分析:通过测试,发现\begin{figure}并不能显示,因为在multicols环境中不能使用figure环境,log中会有warning,故存在问题。
解决方法:
方案一、参见ctex-faQ,59个问题。摘录如下:
如果你使用的是LATEX 标准文档类的twocolumn 模式,那么使用figure 和table 环境可以产生单列的
浮动图形或者表格,而使用figure* 和table* 环境则可以产生通栏的浮动图形或者表格。
如果你使用的是multicol 宏包提供的multicols 环境,那么就有一点小问题了。figure 和table 在这种方式下无法正常工作,会导致图形或者表格丢失。但是, figure* 和table* 仍然可以正常工作,产生通栏的浮动图形或者表格,就像在标准文档类的twocolumn 模式下一样。
要在multicols 环境中使用单栏的图形或者表格,可以使用float 宏包提供的[H] 位置选项。例如
\begin{figure}[H]
...
\caption{...}
\end{figure}\begin{figure}[H]
...
\caption{...}
\end{figure}
但是要注意的是,这种方式产生的对象是不能“浮动”的,也就是说位置是固定的。因此,有时候你必须仔细调整它的位置,以免造成分栏的底部参差不齐。
方案二、在双栏环境下,我们可以不使用figure。可以直接插入图片,居中的话可以用center环境。若是想使用caption和label,导言区加入代码:
这样会让图和表格的标题都以figure ,若是table也正常的话。每次使用前修改为\makeatletter
\def\@captype{table}
\makeatother
或者重新定义为:
\makeatletter
\newcommand\figurecaption{\def\@captype{figure}\caption}
\newcommand\tablecaption{\def\@captype{table}\caption}
\makeatother
然后用\figurecaption{XXX}和\tablecaption{XXX}来加标题吧!
方案三、定义新的环境来使用。
我们直接使用 figurehere 和 tablehere环境就可以了。
问题描述:在article环境下,使用begin{figure}无法显示图片,例子如下:
[code]\documentclass[]{article} \usepackage{multicol} % Used for the two-column layout of the document \usepackage{amsmath} \usepackage{graphicx} \graphicspath{ {pics/} } \title{\vspace{-15mm}\fontsize{24pt}{10pt}\selectfont\textbf{Lorem ipsum}} % Article title \begin{document} \maketitle % Insert title \begin{multicols}{2} % %This does not show up \begin{figure}[h] \includegraphics[width=.4\textwidth]{generalPolya} \end{figure} %This shows up. \begin{center} \includegraphics[width=.5\textwidth]{chair} \end{center} \end{multicols} \end{document}
问题分析:通过测试,发现\begin{figure}并不能显示,因为在multicols环境中不能使用figure环境,log中会有warning,故存在问题。
[code]Package multicol Warning: Floats and marginpars not allowed inside `multicols' environment!.
解决方法:
方案一、参见ctex-faQ,59个问题。摘录如下:
如果你使用的是LATEX 标准文档类的twocolumn 模式,那么使用figure 和table 环境可以产生单列的
浮动图形或者表格,而使用figure* 和table* 环境则可以产生通栏的浮动图形或者表格。
如果你使用的是multicol 宏包提供的multicols 环境,那么就有一点小问题了。figure 和table 在这种方式下无法正常工作,会导致图形或者表格丢失。但是, figure* 和table* 仍然可以正常工作,产生通栏的浮动图形或者表格,就像在标准文档类的twocolumn 模式下一样。
要在multicols 环境中使用单栏的图形或者表格,可以使用float 宏包提供的[H] 位置选项。例如
\begin{figure}[H]
...
\caption{...}
\end{figure}\begin{figure}[H]
...
\caption{...}
\end{figure}
但是要注意的是,这种方式产生的对象是不能“浮动”的,也就是说位置是固定的。因此,有时候你必须仔细调整它的位置,以免造成分栏的底部参差不齐。
方案二、在双栏环境下,我们可以不使用figure。可以直接插入图片,居中的话可以用center环境。若是想使用caption和label,导言区加入代码:
[code]\makeatletter \def\@captype{figure} \makeatother \caption{???}\label{xxx}
这样会让图和表格的标题都以figure ,若是table也正常的话。每次使用前修改为\makeatletter
\def\@captype{table}
\makeatother
或者重新定义为:
\makeatletter
\newcommand\figurecaption{\def\@captype{figure}\caption}
\newcommand\tablecaption{\def\@captype{table}\caption}
\makeatother
然后用\figurecaption{XXX}和\tablecaption{XXX}来加标题吧!
方案三、定义新的环境来使用。
[code]\makeatletter \newenvironment{tablehere} {\def\@captype{table}} {} \newenvironment{figurehere} {\def\@captype{figure}} {} \makeatother
我们直接使用 figurehere 和 tablehere环境就可以了。
相关文章推荐
- 网站统计中的PV-UV-IP的定义与区别
- phpcms内容分页
- PHP - 字符串操作
- angularjs 如何处理checkbox
- 图片相关
- Scala排序简写及效率
- IOS消息推送之APNS
- Less CSS框架的简介
- spring的annotation-driven配置事务管理器详解
- Sass混合宏、继承、占位符
- js alert重写,适用于手机端,改自于网上的代码
- android中控件的使用
- PHP - 自定义函数
- [LintCode] Nuts and Bolts
- 我学习嵌入式linux开发入门过程(二)
- servlet+JSP+mysql实现文件上传的方法
- ScheduledExecutorService实现viewpager的自动切换
- Oracle Advanced Queue (DBMS_AQ/DMBS_AQADM)
- 深入浅出MFC笔记
- Oauth2.0和1.0区别