如果这只是一件小事,我很抱歉...无论如何,
如何在图形标题内插入表格?
我怎样才能在块内插入一个块?
\begin{figure}[h]
\begin{center}
some picture here
\caption{. . . table here . . . !!}
\end{center}
\end{figure}
答案1
里面有\caption
一个表(意思是“表”是一个tabular
环境,而不是一个table
浮动环境!)可能会在几个方面出现问题,例如,为了格式化“图1:“因为\\
在标题内不起作用。另一个例子是制作一个图形列表,因为表格隐藏了整个标题,甚至表格外的文本(无论如何,图形列表中的表格会很糟糕),尽管这可以通过为列表放置可选文本来解决:
\documentclass[a5paper]{article}
\usepackage{mwe}
\begin{document}
\listoffigures
\begin{figure}[h]
\centering
\includegraphics[height=2cm]{example-image}
\caption[A table inside a caption]{
\begin{tabular}{|c|cc|ccc|}
\hline
a & b & c & 1 & 2 & 3 \\\hline
d & e & f & 4 & 5 & 6 \\
g & h & i & 7 & 8 & 9 \\\hline
\end{tabular}}
\end{figure}
\end{document}
要使“图 1”位于表格中央和上方,一个简单的解决方案是将表格环境后标题:
\documentclass[a5paper]{article}
\usepackage{mwe}
\begin{document}
\listoffigures
\begin{figure}[h]
\centering
\includegraphics[height=2cm]{example-image}
\caption[A table inside a caption]{}
\begin{tabular}{|c|cc|ccc|}
\hline
a & b & c & 1 & 2 & 3 \\\hline
d & e & f & 4 & 5 & 6 \\
g & h & i & 7 & 8 & 9 \\\hline
\end{tabular}
\end{figure}
\end{document}
另一个解决方案是避免使用标题,自己处理图片计数器、参考文献和图片列表,但作为对应方,您可以将位置放在\thefigure
您想要的位置,甚至在环境内部tabular
。在 Torbjørn T. 的帮助下,一些示例似乎也适用于cleveref
和hyperref
包:
\documentclass{article}
\usepackage{mwe}
\usepackage[colorlinks=true,linkcolor=blue]{hyperref}
\usepackage{booktabs,cleveref}
\usepackage{multirow}
%\fakecap{caption title in list of figures}{label}
\makeatletter
\newcommand\fakecap[2]{
\refstepcounter{figure}
\addcontentsline{lof}{figure}{\figurename~\thefigure: #1}%
\mbox{\figurename~\thefigure}
\renewcommand\@currentlabel{\thefigure}
\label{fig:#2}}
\makeatother
\begin{document}
\listoffigures
\section{Section One}\label{sec:ccc}
This \cref{sec:ccc} has not figures.
Just to check that counters are not mixed.
\section{Section Two}\label{sec:ddd}
This \cref{sec:ddd} contain the \cref{fig:aaa}
with a table as caption. Whithout using \verb|\caption|,
the float is still correctly numbered and cross-referenced.
\begin{figure}[h]
\centering
\includegraphics[height=35pt]{example-image}
\quad\begin{tabular}[b]{|l|ccccc|}
\hline
\fakecap{Another fake caption}{aaa} & 1 & 2 & 3 & 4 & 5 \\
\hline
Some thing & 6 & -- & 7 & 8 & 9 \\
Another stuf & 0 & 0 & 1 & $\pi$ & $\alpha$ \\
\hline
\end{tabular}
\end{figure}
\section{Section three}\label{sec:eee}
The \verb|\fakecap| could be placed everywere,
inside or outside the table, as well as the image,
as show the \cref{fig:bbb} in this \cref{sec:eee}.
\begin{figure}[h]
\centering
\def\arraystretch{1.85}
\begin{tabular}[b]{cccccc}
\hline
\fakecap{Fake caption in a table}{bbb}
& 1 & 2 & 3 & 4 & 5 \\
\hline
\multirow{3}{*}{%
\includegraphics[width=.34\textwidth]{example-image}}
& 1 & & 4 & 5 & 6 \\
& 3 & 5 & 5 & 8 & 9 \\
& 7 & 2 & 7 & $\frac{2}{4}$ & 3 \\
& $\beta$ & 2 & 6 & 6 & 3 \\
\hline
\end{tabular}
\end{figure}
\end{document}
答案2
您可以使用\raisebox
。例如,
\documentclass{article}
\usepackage[font=small,labelfont={bf,footnotesize}]{caption}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\begin{center}
\includegraphics[scale=0.5]{parabola.pdf}
\caption{
\raisebox{-0.41cm}{
\begin{tabular}{rl}
Ecuaci\'on can\'onica \;&$(y-k)^2\;=\;4p(x-h)$\\
V\'ertice \;& $V=(h,k)$\\
Foco\; & $F=(h+p,k)$
\end{tabular}
}
}
\end{center}
\end{figure}
\end{document}