提问于:
浏览数:
6499
我参考了lshort-zh-cn P35页的参考代码编写的如下代码,
```tex
\documentclass{book}
\usepackage{subfig}
\begin{document}
\begin{figure}[htbp]
\centering
\subfloat[(1)]{
\label{C1T12(1)}
\begin{minipage}
\centering
\end{minipage}
}
\qquad
\subfloat[(2)]{
\label{C1T12(2)}
\begin{minipage}
\centering
\end{minipage}
}
\caption{第12题}
\label{C1T12}
\end{figure}
\end{document}
```
但是报错
行 12: Missing number, treated as zero. ^^I^^I}
行 12: Illegal unit of measure (pt inserted). ^^I^^I}
行 12: Missing number, treated as zero. ^^I^^I}
行 12: Illegal unit of measure (pt inserted). ^^I^^I}
行 19: Missing number, treated as zero. ^^I^^I}
行 19: Illegal unit of measure (pt inserted). ^^I^^I}
行 19: Missing number, treated as zero. ^^I^^I}
行 19: Illegal unit of measure (pt inserted). ^^I^^I}
请问是什么原因,谢谢。
3 回答
0
盲猜 `subfloat` 传参问题。
```tex
\documentclass{article}
\usepackage{subfig}
\usepackage[demo]{graphicx}
\begin{document}
other part of code which compiles fine
\begin{figure}
\centering
\subfloat[][a]{\includegraphics{<figure1>}\label{<figure1>}}
\subfloat[][b]{\includegraphics{<figure2>}\label{<figure2>}}
\caption{Comparison of steady state results (a) x method (b) y method}
\label{steady_state}
\end{figure}
%remaining part
\end{document}
```
reference: https://tex.stackexchange.com/questions/111822/using-subfloat-to-place-figures-side-by-side
学习之余也要会自己多探索,加油啊。
![](https://pics.latexstudio.net/data/images/202002/fd2c897947314ad.png)
回答: 2020-02-16 13:49
![](https://pics.latexstudio.net/data/images/202002/1329f26bd681dcc.png)
效果图忘了放了。
如果要修改默认的`(a), (b)`子图的编号,得具体去查看下`subgif`的手册了。
0
caption用中文得加ctex,加载图片要用graphicx,同时minipage要指定宽度,不能只有\begin{minipage}
\documentclass{book}
\usepackage{subfig,ctex,graphicx}
\begin{document}
\begin{figure}[htbp]
\centering
\subfloat[(1)]{
\label{C1T12(1)}
\begin{minipage}{0.2\textwidth}
\centering
\includegraphics{a.png}
\end{minipage}
}
\qquad
\subfloat[(2)]{
\label{C1T12(2)}
\begin{minipage}{0.2\textwidth}
\centering
\includegraphics{a.png}
\end{minipage}
}
\caption{第12题}
\label{C1T12}
\end{figure}
\end{document}
0
```tex
\documentclass{book}
\usepackage{subfig}
\usepackage{mwe}
\begin{document}
\begin{figure}
\centering
\subfloat[subfig one\label{C1T12-1}]{\includegraphics[width=0.4\linewidth]{example-image}}
\quad
\subfloat[subfig two\label{C1T12-2}]{\includegraphics[width=0.4\linewidth]{example-image}}
\caption{number 12}\label{C1T12}
\end{figure}
\end{document}
```
运行一下上面的代码看看
你的回答
请登录后回答
你的回答将会帮助更多人,请务必认真回答问题。