【LaTeX】子图使用问题

1. missing number treated as zero subfigure

使用了 subfigure 包,这个包已经被淘汰很久了,使用它会导致错误。

\begin{figure}[htbp]
   \centering
   \begin{subfigure}
       \centering
       \includegraphics[width=0.2\textwidth]{fig/four_SAXS.png}
       \caption{SAXS}
   \end{subfigure}
   \qquad
   \begin{subfigure}
       \centering
       \includegraphics[width=0.2\textwidth]{fig/four_AFM.png}
       \caption{AFM}
   \end{subfigure}
\end{figure}

将subfigure改为subcaption宏包或其他实现方法

2. 使用minipage实现排版

https://dalewushuang.blog.csdn.net/article/details/108781140

\begin{figure}[htbp]
    \centering
    \begin{minipage}{0.2\textwidth}
        \centering
        \includegraphics[width=.50\linewidth]{fig/A.png}
        \caption{img A}
        \label{fig:A}
    \end{minipage}
    \begin{minipage}{0.2\textwidth}
        \centering
        \includegraphics[width=.69\linewidth]{fig/B.png}
        \caption{img B}
        \label{fig:B}
    \end{minipage}
    \caption{Two Imgs}
\end{figure}

效果:
在这里插入图片描述

这样是两个Fig,并且会占用计数。
我们想要的效果是一个Fig,Fig中是(a)、(b)、( c )。(d),就需要在minipage中使用subcaption宏包实现子图的标题设置。

3.subcaption使用

暂时找到的几个办法都会出错,感觉代码没问题,但好像与模板样式中引用的宏包发生冲突,subfigure package和subcaption 这个package是不可以同时调用。
http://blog.sina.com.cn/s/blog_7e1870780102vxg5.html
待进一步找到原因和解决办法

4.不用minipage,只用subfloat实现

https://blog.csdn.net/u012428169/article/details/115449123

\begin{figure}[htbp]
    \centering
    \subfloat[IMG A]{\includegraphics[width=0.2\textwidth]{fig/A.png}}
    \hfill
    \subfloat[IMG B]{\includegraphics[width=0.2\textwidth]{fig/B.png}}
    \newline
    \subfloat[IMG C]{\includegraphics[width=0.2\textwidth]{fig/C.png}}
    \hfill
    \subfloat[IMG D]{\includegraphics[width=0.2\textwidth]{fig/D.png}}
    \caption{Four Imgs}
\end{figure}

\newline为另起一行

效果:

在这里插入图片描述
只需要根据高度、宽度、位置分布进行一些微调即可。
可以看到上面的效果中间的间距有点大,因为我们使用\hfill来填充空白。

想要减少间距,可以使用\hspace{5mm},让AB两个图片之间的间距为5mm。

设置间距的命令为:

水平间隔

\hspace{长度} : 插入指定距离的水平空白间隔。
\hphantom{文本}:插入指定“文本”宽度的水平空白。
\hfill:填充空白。
\dotfill:以虚线填充空白。
\hrulefill:以直线填充空白。

垂直间隔

\vspace{长度}:在当前行下面插入指定长度的竖直间隔。

5.newline的问题

参考:https://www.zhihu.com/question/413783380/answer/1407363306

在4中,我们要做两行两列的子图。
在上面4的示例图片中,效果很好,水平和垂直方向对齐都很好,但是效果好的原因是因为我们使用了\hfill填充,且四张图片的大小都是一样的,所以效果很好。

当我们使用\hspace缩小子图之间的距离时,如果图片大小都相同,对齐效果依然很好;但当四张图片的长宽各异时,就会出现对不齐的情况。

这个时候只需要将上面的\newline去掉,改为空一格即可。

6.latex中一列中图片过多问题

我们使用子图的时候,一个大的图片里面可能放了四、五个子图,在latex里面,这些图片都是单独看待的,有标题、有长度等。

当latex中某一列有很多图片时,在后面追加一个图片可能导致图片浮动到下一页,达不到想要的效果。

只需要将下面的[t]改为[!t]即可

\begin{figure}[t]
	xxxxxx
\end{end}

参考:

https://stackoverflow.com/questions/60684062/latex-subfloat-the-subcaption-is-one-word-in-one-line-how-to-make-them-togeth
https://tex.stackexchange.com/questions/461417/how-to-put-3-figures-in-latex-with-2-figures-side-by-side-and-1-below-these-side
https://dalewushuang.blog.csdn.net/article/details/108781140
https://blog.csdn.net/xiazdong/article/details/8893374
https://blog.csdn.net/kane7csdn/article/details/101438813

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

KyrieLiu52

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值