tex4ht: `hyperref`의 `backref` 옵션이 제대로 작동하지 않습니다.

tex4ht: `hyperref`의 `backref` 옵션이 제대로 작동하지 않습니다.

MWE:

\documentclass{article}
\usepackage[backref=page]{hyperref}

\renewcommand*{\backref}[1]{}
\renewcommand*{\backrefalt}[4]{[{\tiny%
      \ifcase #1 Not cited%
      \or Cited in page~#2.%
      \else Cited in pages #2.%
      \fi%
}]}

\begin{document}  
\cite{foo,bar,hole}

\begin{thebibliography}{9}
\bibitem{foo} foo

\bibitem{bar} bar

\bibitem{hole} hole

\end{thebibliography}  
\end{document}

에서 컴파일하는 동안에는 문제가 없습니다 tex4ebook. 그러나 역참조 링크가 끊어졌습니다. 해결 방법이 있습니까(또는 역참조는 전자책에 대한 좋은 개념으로 간주되지 않습니다)?

답변1

이것은 그렇게 쉬운 일이 아닙니다. 역참조 옵션은 페이지에 대한 링크를 다시 삽입합니다. 페이지는 HTML 파일에 존재하지 않으므로 아무 곳도 가리키지 않습니다.

필요한 것은 각 \cite명령에 대해 고유 ID를 생성하는 것입니다. 그러면 다시 연결할 수 있습니다. 다음 .cfg파일을 사용해 보세요:

\Preamble{xhtml}
\makeatletter

\newcounter{citelinkcnt}
\newcommand\citelink[2]{%
% Generate ID for the current citation
\stepcounter{citelinkcnt}%%
\@ifundefined{#1-\thepage}{% Save the information only once
% Save the generated ID to the xref file
\Tag{backlink-#1-\thepage}{bk-#1\thecitelinkcnt}%
% Save the current HTML file
\Tag{filename-#1-\thepage}{\FileName}%
}{}%
\global\@namedef{#1-\thepage}{}%
% Insert link to the bibliography and the current ID
\Link{#1}{bk-#1\thecitelinkcnt}%
}

% Save the current bibkey, we will need it to get the correct backref
\newcommand\mybiblink[2]{\Link{#1}{#2}\def\currentbibitem{#2}}
% Insert the back link
\renewcommand\backrefxxx[3]{\Link[\LikeRef{filename-\currentbibitem-#1}]{\LikeRef{backlink-\currentbibitem-#1}}{}#1\EndLink}
\makeatother

% Configure cite to save the citation ID
\Configure{cite}
   {\HCode{<span class="cite">}}  {\HCode{</span>}}
   {\citelink}         {\EndLink}

% Configure bibitem to save the bibkey
\Configure{bibitem}{\mybiblink}{\EndLink}
\begin{document}
\EndPreamble

중요한 부분은 다음과 같습니다.

\newcounter{citelinkcnt}
\newcommand\citelink[2]{%
% Generate ID for the current citation
\stepcounter{citelinkcnt}%%
\@ifundefined{#1-\thepage}{% Save the information only once
% Save the generated ID to the xref file
\Tag{backlink-#1-\thepage}{bk-#1\thecitelinkcnt}%
% Save the current HTML file
\Tag{filename-#1-\thepage}{\FileName}%
}{}%
\global\@namedef{#1-\thepage}{}%
% Insert link to the bibliography and the current ID
\Link{#1}{bk-#1\thecitelinkcnt}%
}

\citelink명령은 생성된 HTML 파일에 다음 코드를 삽입합니다. <a id='bk-Xfoo1' href='#Xfoo'>1</a>. 각 속성은 고유 해야 하므로 속성은 접두사, 현재 인용 키 및 카운터를 사용 하여 id해석됩니다 .bk-\citeid

\Tag명령은 현재 HTML 파일 및 파일 id에 대한 정보를 저장합니다 .xref. 이 정보는 나중에 다시 연결하는 데 사용됩니다. 인용 키와 페이지 번호를 사용하여 각 에 대한 고유한 값을 얻습니다 \cite. 인용 키가 한 페이지에서 두 번 이상 사용되면 그 중 하나만 연결할 수 있으므로 첫 번째 키만 저장됩니다.

뒤로 링크는 다음 코드를 사용하여 삽입됩니다.

% Save the current bibkey, we will need it to get the correct backref
\newcommand\mybiblink[2]{\Link{#1}{#2}\def\currentbibitem{#2}}
% Insert the back link
\renewcommand\backrefxxx[3]{\Link[\LikeRef{filename-\currentbibitem-#1}]{\LikeRef{backlink-\currentbibitem-#1}}{}#1\EndLink}

\backrefxxx명령은 링크를 삽입합니다. 이 \Link명령은 대상 파일 이름을 대괄호 안의 인수로 사용하고 다음 매개변수에는 대상 ID가 포함됩니다. 이 \LikeRef명령은 파일에서 정보를 검색합니다 .xref. 다음 코드를 생성합니다.

 Cited in pages </span><a href='sample.html#bk-Xfoo1'><span class='cmr-5'>1</span></a> <span class='cmr-5'>and </span><a href='sample.html#bk-Xfoo5'><span class='cmr-5'>4</span></a>

관련 정보