我没有得到将 TikZ 文件并排放置的正确结果:
\documentclass[12pt,a4paper]{report}
\usepackage{pgfplots}
\usepackage{graphicx}
\usepackage{tikz}
\begin{document}
\begin{figure}[!htb]
\begin{minipage}[l]{0.5\textwidth}
\centering
\newlength\figureheight
\newlength\figurewidth
\setlength\figureheight{5cm}
\setlength\figurewidth{8cm}
%\input{a.tikz}
\begin{tikzpicture}
\draw (0.1,0) -- (0.9,0);
\end{tikzpicture}
\subcaption{(a)}
\end{minipage}\hfill%
\begin{minipage}[l]{0.5\textwidth}
\centering
\newlength\figureheight
\newlength\figurewidth
\setlength\figureheight{5cm}
\setlength\figurewidth{8cm}
%\input{b.tikz}
\begin{tikzpicture}
\draw (0.1,0) -- (0.9,0);
\end{tikzpicture}
\subcaption{(b)}
\end{minipage}%
\caption{Caption}
\end{figure}
\end{document}
答案1
您需要包subcaption
。最好在序言中引入长度figureheight
和figurewidth
,这样您就不会弄得太乱。您可能会混淆,因为您以与索引相同的方式调用子标题。
如果您仍然遇到错误,则可能是因为您的 tikz 图形中存在错误。
\documentclass[12pt,a4paper]{report}
\usepackage{pgfplots}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{tikz}
\newlength\figureheight
\newlength\figurewidth
\begin{document}
\begin{figure}[!htb]
\begin{minipage}[l]{0.5\textwidth}
\centering
\setlength\figureheight{5cm}
\setlength\figurewidth{8cm}
\begin{tikzpicture}
\draw (0.1,0) -- (0.9,0);
\end{tikzpicture}
\subcaption{(a)}
\end{minipage}\hfill%
\begin{minipage}[l]{0.5\textwidth}
\centering
\setlength\figureheight{5cm}
\setlength\figurewidth{8cm}
\begin{tikzpicture}
\draw (0.1,0) -- (0.9,0);
\end{tikzpicture}
\subcaption{(b)}
\end{minipage}%
\caption{Caption}
\end{figure}
\end{document}