결합된 캡션을 사용하여 그림과 표(동일한 그림 환경에서)의 독립적인 레이블 지정

결합된 캡션을 사용하여 그림과 표(동일한 그림 환경에서)의 독립적인 레이블 지정

내 문서에서 그림과 표(~\ref{} 포함)를 참조하려고 합니다. 두 요소를 그림 환경(그림이 먼저, 표가 두 번째, 둘 다 미니페이지 내부에 있음)에 배치하여 서로 옆에 표시되도록 했습니다. 더 나은 보기를 위해 결합된 캡션을 사용하고 있습니다. 라벨 문제에 대한 해결책을 찾았습니다.밥을 먹이다. 이제 내 그림과 테이블을 호출할 수 있습니다. 다만, 표 참조는 그림번호와 연관되어 있는 것으로 보인다. 문제는 내 문서에 일반 환경의 그림과 표가 있는데 이 결합된 그림/표가 나타나는 위치의 카운터가 그림과 표에 대해 동일하지 않다는 것입니다.

올바른 표와 그림 번호를 표시하기 위해 이 문제를 해결하는 방법에 대한 제안 사항이 있는 사람이 있습니까? 내 서문에서 나는 또한 정의했습니다.이것:

\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>}(패키지 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}

관련 정보