
私は自分の文書で図と表を参照しようとしています(~\ref{}を使用)。両方の要素を、図環境(図を先頭、表を2番目、両方ともミニページ内)に配置して、隣り合って表示されるようにしました。見栄えを良くするために、結合されたキャプションを使用しています。ラベルの問題の解決策は、この餌これで、図と表を呼び出すことができます。ただし、表の参照は図番号に関連付けられているようです。問題は、ドキュメント内に通常の環境にある図と表があり、この結合された図/表が表示される場所のカウンターが図と表で同じではないことです。
正しい表と図の番号を表示するためにこれを修正する方法について、誰か提案はありますか?私の序文では、次のように定義しました。これ:
\DeclareCaptionLabelFormat{figandtab}{#1~#2 \& \tablename~\thetable}
図と表を組み合わせたキャプションを使用できるようにします。正常に動作しており、正しい図と表の番号が記載されています。ラベルと参照が正しいカウンターで動作していないだけです。
図/表に使用したものは次のとおりです。
\begin{figure}[h]
\centering
\begin{minipage}{0.49\textwidth}
\centering
\includegraphics[width=1.0\columnwidth]{picture.jpg}%}
\end{minipage}
\begin{minipage}{0.49\textwidth}
\centering
\captionsetup{type=table}
\resizebox{0.9\linewidth}{!}{%
\begin{tabular}{lll}
*my table contents*
\end{tabular}%
}
\end{minipage}
\captionsetup{labelformat=figandtab}
\caption{combined caption}
\label{fig:figure_label}
{\makeatletter\edef\@currentHref{table.caption.\the\c@table}\label{tab:table_label}}
\end{figure}
ご協力いただければ幸いです!
答え1
コマンド\captionof{<figure or table>}{<text>}
(package caption
) を使うことができます。これですべての宿題が処理されます。
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{caption} % needed <<<<<<<<<<<<<<<<<<<<<<
\begin{document}
\listoftables
\listoffigures
\begin{figure}[h]
\centering
\begin{minipage}{0.49\textwidth}
\centering
\includegraphics[width=1.0\linewidth]{example-image}%}
\end{minipage}
\begin{minipage}{0.49\textwidth}
\centering
\captionof{table}{A table caption}\label{tab:table_label}
\resizebox{0.9\linewidth}{!}{%
\begin{tabular}{lll}
*my table contents*
\end{tabular}%
}
\end{minipage}
\captionof{figure}{combined caption}
\label{fig:figure_label}
\end{figure}
See the figure~\ref{fig:figure_label} and the adjoining table~\ref{tab:table_label}.
\end{document}
答え2
これは と同じ機能を実行します\caption
。ハイパーリンクはミニページの上部に移動することに注意してください。
\documentclass{article}
\usepackage{graphicx}
\usepackage{hyperref}
\begin{document}
\listoffigures
\listoftables
\begin{figure}[ht]
\centering
\begin{minipage}{0.49\textwidth}
\refstepcounter{figure}\label{fig:figure label}%
\addcontentsline{lof}{figure}{\protect\numberline{\thefigure}LOF caption}%
\centering
\includegraphics[width=\linewidth]{example-image}%}
\end{minipage}
\begin{minipage}{0.49\textwidth}
\refstepcounter{table}\label{tab:table_label}%
\addcontentsline{lot}{table}{\protect\numberline{\thetable}LOT caption}%
\centering
\resizebox{0.9\linewidth}{!}{%
\begin{tabular}{lll}
*my table contents*
\end{tabular}%
}
\end{minipage}
\par\vskip\abovecaptionskip
\figurename~\thefigure~\&~\tablename~\thetable: yadda yadda yadda
\par\vskip\belowcaptionskip
\end{figure}
Link to \figurename~\ref{fig:figure label} and \tablename~\ref{tab:table_label}.
\end{document}