本文にキャプションテキストを挿入する

本文にキャプションテキストを挿入する

コマンド\refは、次のコードのように、テーブル番号のみを参照できます。

\documentclass{article}
\begin{document}
According to Table \ref{table} [[HERE]], we blah blah.
\begin{table}[tb]
  \caption{The caption of the table}
  \label{table}
  \begin{center}
    \begin{tabular}{ll}\hline foo & bar \\ \hline\end{tabular}
  \end{center}
\end{table}
\end{document}

\refキャプションテキストを本文の後ろ(位置[[HERE]])に挿入したいと思います。

のように

表 1 の「表のキャプション」によれば、私たちはこうなります。

ない

表 1 によれば、私たちはこうなります。

本文にキャプションテキストを挿入する方法はありますか?

答え1

たとえば、パッケージnamerefまたはtitleref提供は、キャプション (およびセクションなど) のタイトルを参照します。

\documentclass{article}
\usepackage{booktabs}% nicer table lines
\usepackage{nameref}
\usepackage{csquotes}% quotes with multilingual support
\usepackage{caption}% fixes the spacing around caption for tables
\begin{document}
According to Table \ref{table} \enquote{\nameref{table}}, we blah blah.
\begin{table}[tb]
  \centering % avoids additional vertical space of environment center
  \caption{The caption of the table}
  \label{table}
  \begin{tabular}{ll}
    \toprule
    foo & bar \\
    \bottomrule
  \end{tabular}
\end{table}
\end{document}

結果

パッケージ付きtitleref:

\usepackage{titleref}
...\titleref{...}...

追加のヒントについてはコメントも参照してください。

関連情報