endfloat의 마커에 하이퍼링크를 넣는 방법은 무엇입니까?

endfloat의 마커에 하이퍼링크를 넣는 방법은 무엇입니까?

문서의엔드 플로트패키지는 "[여기에 대한 표 3.]"의 기본값에서 마커의 텍스트를 사용자 정의하는 방법을 설명합니다. 하지만 문서 끝에 있는 그림에 대한 하이퍼링크를 포함하도록 마커를 사용자 정의하고 싶습니다. 이것이 어떻게 이루어질 수 있습니까?

다음은 하위 질문입니다. 마커를 사용자 정의할 때 \thepostfigure그림 번호를 참조합니다. \thefigurereference마커 텍스트가 다음과 같을 수 있도록 그림에 대한 참조를 참조하는 유사한 명령이 있습니까 Figure \ref{\thefigurereference}} about here.?

업데이트 2:댓글에서 백링크에 대해서도 질문했는데, 문서 끝에 있는 그림의 캡션이 텍스트에 포함된 "[여기에 대한 그림 1]" 플로트로 다시 하이퍼링크되도록 했습니다. @John Kormylo가 수용한 솔루션이 이를 제공합니다.

업데이트 1 [수정된 답변이 아닌 @John Kormylo의 원래 답변을 참조하여 더 명확하게 편집됨]:

@John Kormylo의 (원본) 솔루션은 작동하지만 내가 배운 것처럼 하위 캡션 패키지와 호환되지 않습니다. 그래서 수정된 질문은 다음과 같습니다. 캡션과 함께 작동하는 그림에 하이퍼링크하는 방법이 있습니까?

다음은 하이퍼링크가 끝에 있는 그림으로 이동하지 않는 솔루션을 사용하는 MWE입니다. 그림 2는 하위 캡션이 필요한 이유를 보여주기 위한 것입니다. 하위 캡션 패키지가 사용되는 한 하위 캡션이 없어도 연결이 여전히 실패합니다.

\documentclass{article}
\usepackage{endfloat}
\usepackage{mwe}
\usepackage{hyperref}
\usepackage{subcaption}

% John Kormylo's original solution, which works when the subcaption package isn't used:
\renewcommand{\floatplace}[1]{% #1 = float type (e.g. figure)
   \begin{center}
     \hyperlink{#1.\csname thepost#1\endcsname}%
       {[\csname #1name\endcsname~\csname thepost#1\endcsname\ about here.]}
   \end{center}}

\begin{document}

\begin{figure}
\includegraphics{example-image}
\caption{A figure without subfigures}
\end{figure}

\begin{figure}[htb]
\centering
\begin{subfigure}{.5\textwidth}
  \centering
    \includegraphics[width=.9\textwidth]{example-image}
  \caption{first part}
\end{subfigure}%
%
\begin{subfigure}{.5\textwidth}
  \centering
    \includegraphics[width=.9\textwidth]{example-image}
  \caption{(second part)}
\end{subfigure}%
\caption{A figure with subfigures}
\end{figure}

\lipsum[1-2]


\end{document}

생성된 파일 aux은 솔루션이 작동하지 않은 이유가 하위 캡션이 카운터 이름을 등에서 등으로 변경하기 때문임을 시사 figure.1합니다 figure.2. figure.caption.2테이블 figure.caption.3목록에 대해 다음 줄이 있습니다(그림에 대한 하이퍼링크가 작동 중임).

\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces This is figure 1.\relax }}{3}{figure.caption.2}}
\@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces This is figure 2.\relax }}{4}{figure.caption.3}}

\floatplace한 가지 옵션은 John Kormylo의 (원래) 명령을 2에서 시작하여 번호를 매기고 헤드 이름을 figure.caption또는 로 다시 작성하는 것입니다 table.caption. 그러나 다른 문서에서는 figure.captionaux 파일의 번호가 18부터 시작합니다. (하지만 MWE에서 이것을 재현하는 방법을 찾지 못했습니다.) 이는 그러한 해결 방법이 작동하지 않음을 의미합니다.

답변1

명명 \caption된 .\refstepcounter{figure}\hypertarget\@currentHref안타깝게도 (실제로는 ) \floatplace에만 액세스할 수 있습니다 . 따라서 aux 파일을 통해 에서 까지 의 맵을 문서의 시작 부분으로 이동해야 합니다. 이것과 백링크를 결합하기 위해 .\thefigure\thepostfigure\thefigure\@currentHref\caption\figurecaption

원본을 유지하면서 \floatplace플로트 유형을 독립적으로 만들었습니다. 그러나 \figurecaption및 에 대한 코드만 추가했습니다 \newfigure.

\documentclass{article}
\usepackage{endfloat}
\usepackage{mwe}
\usepackage{subcaption}
\usepackage{hyperref}

\makeatletter
\renewcommand{\floatplace}[1]{% #1 = float type (e.g. figure)
   \begin{center}
     \def\floatnumber{\csname thepost#1\endcsname}
     \def\floatname{\csname #1name\endcsname}
     \hypertarget{figureback\floatnumber}{}%
     \@ifundefined{#1anchor\floatnumber}%
       {[\floatname~\floatnumber\ about here.]}%
       {\hyperlink{\csname #1anchor\floatnumber\endcsname}%
         {[\floatname~\floatnumber\ about here.]}}
   \end{center}}

\newcommand{\figurecaption}[2][\empty]% #1=short caption (optional), #2=caption
 {\ifx\empty#1\relax \caption[#2]{\hyperlink{figureback\thefigure}{#2}}%
  \else \caption[#1]{\hyperlink{figureback\thefigure}{#2}}%
  \fi
  \immediate\write\@auxout{\string\newfigure{\thefigure}{\@currentHref}}}
\makeatother

\newcommand{\newfigure}[2]% #1 = \thefigure, #2 = \@currentHref
  {\expandafter\gdef\csname figureanchor#1\endcsname{#2}}

\begin{document}

\begin{figure}
\includegraphics{example-image}
\figurecaption{A figure without subfigures}
\end{figure}

\begin{figure}[htb]
\centering
\begin{subfigure}{.5\textwidth}
  \centering
    \includegraphics[width=.9\textwidth]{example-image}
  \caption{first part}
\end{subfigure}%
%
\begin{subfigure}{.5\textwidth}
  \centering
    \includegraphics[width=.9\textwidth]{example-image}
  \caption{(second part)}
\end{subfigure}%
\figurecaption{A figure with subfigures}
\end{figure}

\lipsum[1-2]

\end{document}

이상한 명명 규칙 하위 캡션이 적용되는 것과 상관없이 작동합니다.

답변2

표와 그림에 대해서도 동일한 작업을 수행하는 동시에 용어집 패키지의 오류를 확인해야 했습니다. (내 생각엔 어딘가에 정의된 "tablecaption" 함수가 있을 수도 있습니다.)
여기 있습니다:

\documentclass{scrartcl}
\usepackage{graphicx}
\usepackage{xcolor} %Farben
\usepackage{hyperref} %Links
\usepackage[nolists]{endfloat} % figures mit platzhalter und dann im Anhang
\renewcommand{\efloatseparator}{\mbox{}}
\usepackage{glossaries}
\usepackage{ifthen}

\usepackage{caption}
\usepackage{subcaption}
\usepackage{mwe}

\makeatletter
\renewcommand{\floatplace}[1]{% #1 = float type (e.g. figure)
    \begin{center}
        \def\floatnumber{\csname thepost#1\endcsname}
        \def\floatname{\csname #1name\endcsname}

        \ifthenelse{\equal{#1}{figure}}% define backlink based on figure or table
        {\def\backlink{figureback\floatnumber}}%
        {\def\backlink{tableback\floatnumber}}%

        \colorbox{yellow}{\floatname}
        \colorbox{red}{\backlink}

        \colorbox{orange}{\floatnumber}
        \colorbox{green}{\csname #1anchor\floatnumber\endcsname}

        \hypertarget{\backlink}{}
        \@ifundefined{#1anchor\floatnumber}%
        {[ \floatname~\floatnumber\ about here. ]}%
        {[ \hyperlink{\csname #1anchor\floatnumber\endcsname}%
            {\floatname~\floatnumber} about here. ]}
    \end{center}
}

%for figure
\newcommand{\figurecaption}[2][\empty]% #1=short caption (optional), #2=caption
{%
    \ifx\empty#1\relax %
        \caption[#2]{\hyperlink{figureback\thefigure}{#2}}%
    \else %
        \caption[#1]{\hyperlink{figureback\thefigure}{#2}}%
    \fi
    \immediate\write\@auxout{\string\newfigure{\thefigure}{\@currentHref}}%
}
\makeatother

\newcommand{\newfigure}[2]% #1 = \thefigure, #2 = \@currentHref
{\expandafter\gdef\csname figureanchor#1\endcsname{#2}}

\makeatletter
%for table
\newcommand{\tabcaption}[2][\empty]% #1=short caption (optional), #2=caption (tabcaption instead of tablecaption for glossaries)
{%
    \ifx\empty#1\relax %
        \caption[#2]{\hyperlink{tableback\thetable}{#2}}%
    \else %
        \caption[#1]{\hyperlink{tableback\thetable}{#2}}%
    \fi
    \immediate\write\@auxout{\string\newtable{\thetable}{\@currentHref}}%
}
\makeatother

\newcommand{\newtable}[2]% #1 = \thetable, #2 = \@currentHref
{\expandafter\gdef\csname tableanchor#1\endcsname{#2}}

\begin{document}
    \begin{table}
        \tabcaption{tab}
        \begin{tabular}{lcr}
            1 & 2 & 3 \\
        \end{tabular}
    \end{table}

    \begin{figure}
        \includegraphics{example-image}
        \figurecaption{A figure without subfigures}
    \end{figure}

    \begin{figure}[htb]
        \centering
        \begin{subfigure}{.5\textwidth}
            \centering
            \includegraphics[width=.9\textwidth]{example-image}
            \caption{first part}
        \end{subfigure}%
        %
        \begin{subfigure}{.5\textwidth}
            \centering
            \includegraphics[width=.9\textwidth]{example-image}
            \caption{(second part)}
        \end{subfigure}%
        \figurecaption{A figure with subfigures}
    \end{figure}

    \lipsum[1-2]
\end{document}

관련 정보