
예를 들어 Firefox 에서 생성된 PDF를 열면 pdflatex
참조 위로 마우스를 가져가면 URL에 내부 Bibkey가 표시됩니다. 어떻게 하면 이를 방지할 수 있나요?
다음 MWE를 고려하십시오.
mwe.tex
\documentclass{article}
\usepackage[backend=biber]{biblatex}
\addbibresource{bib.bib}
\usepackage{hyperref}
\begin{document}
Test\cite{secretbibkey}
\printbibliography
\end{document}
턱받이.bib
@article{secretbibkey,
author = {Joe},
title = {Just a title},
number = {ABCD-E/2008/ab/1234},
institution = {University},
year = {2008}
}
이제 다음 스크린샷을 살펴보세요.
인용문 위로 마우스를 가져갈 때 사용한 턱받이가 표시됩니다(분명히 스크린샷에는 커서가 포함되어 있지 않지만 녹색 "1" 위에 있었습니다). 이러한 URL 키를 무작위화/익명화할 수 있는 방법이 있나요?
답변1
이런 식으로 시도해 볼 수 있습니다. 대상에 나타날 수 있는 모든 문자와 입력을 처리하는지, 동일한 대상으로 이어질 수 있는지는 확실하지 않지만 \int_to_alpha
지금까지 제가 찾은 최고의 확장 가능한 기능이었습니다. 모든 대상을 스크램블하고 섹션 및 레이블도 스크램블합니다. 턱받이 키만 스크램블하려면 코드를 여러 번 변경해야 합니다 biblatex
.
\documentclass{article}
\usepackage[backend=biber]{biblatex}
\addbibresource{test.bib}
\usepackage{hyperref}
\ExplSyntaxOn
\cs_new:Npn \pix_scrample_dest:n #1 {\int_eval:n{\int_from_alph:n{#1} + 2}} %2= secret number
\def\HyperDestNameFilter#1{\exp_args:Ne\tl_map_function:nN {#1}\pix_scrample_dest:n}
\ExplSyntaxOff
\begin{document}
Test\cite{secretbibkey}
\printbibliography
\end{document}
답변2
모든 내부 라벨을 숨기고 싶다면 Ulrike의답변훨씬 더 좋지만 biblatex
MD5 해시를 통해 생성된 링크만 난독화하는 방법이 있습니다. MD5 해시는 더 이상 보안에 중요한 작업에는 권장되지 않지만 귀하의 목적에는 충분할 수 있습니다.
여기에 사용된 명령에는 \blx@mdfivesum
비교적 최신 biblatex
버전이 필요합니다. 만약 당신이 오래된 에 붙어 있다면 biblatex
, \usepackage{pdftexcmds}
자신을 로드하고 말하십시오 \let\blx@mdfivesum\pdf@mdfivesum
.
아이디어는 모든 링크 명령을 입력 키 사용에서 입력 키의 해시 버전으로 변경하는 것입니다.
\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=authoryear, backend=biber]{biblatex}
\usepackage{hyperref}
\makeatletter
\AtBeginDocument{%
\protected\def\blx@anchor{%
\xifinlist{\the\c@refsection @\blx@mdfivesum{\abx@field@entrykey}}{\blx@anchors}
{}
{\listxadd\blx@anchors{\the\c@refsection @\blx@mdfivesum{\abx@field@entrykey}}%
\hypertarget{cite.\the\c@refsection @\blx@mdfivesum{\abx@field@entrykey}}{}}}%
\ifundef\hyper@natanchorstart
{\long\def\blx@bibhyperref[#1]#2{%
\blx@sfsave\hyperlink{cite.\the\c@refsection @\blx@mdfivesum{#1}}{\blx@sfrest
#2%
\blx@sfsave}\blx@sfrest}%
\protected\long\def\blx@imc@bibhyperlink#1#2{%
\blx@sfsave\hyperlink{cite.\the\c@refsection:\blx@mdfivesum{#1}}{\blx@sfrest
#2%
\blx@sfsave}\blx@sfrest}%
\protected\long\def\blx@imc@bibhypertarget#1#2{%
\blx@sfsave\hypertarget{cite.\the\c@refsection:\blx@mdfivesum{#1}}{\blx@sfrest
#2%
\blx@sfsave}\blx@sfrest}}%
{\long\def\blx@bibhyperref[#1]#2{%
\blx@sfsave\hyper@natlinkstart{\the\c@refsection @\blx@mdfivesum{#1}}\blx@sfrest
#2%
\blx@sfsave\hyper@natlinkend\blx@sfrest}%
\protected\long\def\blx@imc@bibhyperlink#1#2{%
\blx@sfsave\hyper@natlinkstart{\the\c@refsection:\blx@mdfivesum{#1}}\blx@sfrest
#2%
\blx@sfsave\hyper@natlinkend\blx@sfrest}%
\protected\long\def\blx@imc@bibhypertarget#1#2{%
\blx@sfsave\hyper@natanchorstart{\the\c@refsection:\blx@mdfivesum{#1}}\blx@sfrest
#2%
\blx@sfsave\hyper@natanchorend\blx@sfrest}}}
\makeatother
\addbibresource{biblatex-examples.bib}
\begin{document}
\autocite{sigfridsson,worman,geer,nussbaum}
\printbibliography
\end{document}
숫자 지정자를 선호하는 경우(위의 해시와 달리 입력 키에서 전혀 파생되지 않음) 다음을 사용하십시오.
\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=authoryear, backend=biber]{biblatex}
\usepackage{hyperref}
\makeatletter
\newcounter{blx@refnocount}
\newcommand*{\blx@getrefnocount}[1]{%
\xifinlistcs{#1}{blx@refcounts@\the\c@refsection}
{}
{\stepcounter{blx@refnocount}%
\csnumgdef{blx@refcount@\the\c@refsection @#1}{\value{blx@refnocount}}%
\listcsxadd{blx@refcounts@\the\c@refsection}{#1}}%
\letcs\blx@thisrefcount{blx@refcount@\the\c@refsection @#1}}
\AtBeginDocument{%
\ifundef\hyper@natanchorstart
{\protected\def\blx@anchor{%
\xifinlist{\the\c@refsection @\abx@field@entrykey}{\blx@anchors}
{}
{\listxadd\blx@anchors{\the\c@refsection @\abx@field@entrykey}%
\blx@getrefnocount{\abx@field@entrykey}%
\hypertarget{cite.\the\c@refsection @blxlinkno\blx@thisrefcount}{}}}%
\long\def\blx@bibhyperref[#1]#2{%
\blx@getrefnocount{#1}%
\blx@sfsave
\hyperlink{cite.\the\c@refsection @blxlinkno\blx@thisrefcount}
{\blx@sfrest
#2%
\blx@sfsave}\blx@sfrest}%
\protected\long\def\blx@imc@bibhyperlink#1#2{%
\blx@getrefnocount{#1}%
\blx@sfsave
\hyperlink{cite.\the\c@refsection:blxlinkno\blx@thisrefcount}
{\blx@sfrest
#2%
\blx@sfsave}\blx@sfrest}%
\protected\long\def\blx@imc@bibhypertarget#1#2{%
\blx@getrefnocount{#1}%
\blx@sfsave
\hypertarget{cite.\the\c@refsection:blxlinkno\blx@thisrefcount}
{\blx@sfrest
#2%
\blx@sfsave}\blx@sfrest}}%
{\protected\def\blx@anchor{%
\xifinlist{\the\c@refsection @\abx@field@entrykey}{\blx@anchors}
{}
{\listxadd\blx@anchors{\the\c@refsection @\abx@field@entrykey}%
\blx@getrefnocount{\abx@field@entrykey}%
\hyper@natanchorstart{\the\c@refsection @blxlinkno\blx@thisrefcount}%
\hyper@natanchorend}}%
\long\def\blx@bibhyperref[#1]#2{%
\blx@getrefnocount{#1}%
\blx@sfsave
\hyper@natlinkstart{\the\c@refsection @blxlinkno\blx@thisrefcount}%
\blx@sfrest
#2%
\blx@sfsave\hyper@natlinkend\blx@sfrest}%
\protected\long\def\blx@imc@bibhyperlink#1#2{%
\blx@getrefnocount{#1}%
\blx@sfsave
\hyper@natlinkstart{\the\c@refsection:blxlinkno\blx@thisrefcount}%
\blx@sfrest
#2%
\blx@sfsave\hyper@natlinkend\blx@sfrest}%
\protected\long\def\blx@imc@bibhypertarget#1#2{%
\blx@getrefnocount{#1}%
\blx@sfsave
\hyper@natanchorstart{\the\c@refsection:blxlinkno\blx@thisrefcount}%
\blx@sfrest
#2%
\blx@sfsave\hyper@natanchorend\blx@sfrest}}}
\makeatother
\addbibresource{biblatex-examples.bib}
\begin{document}
\autocite{sigfridsson,worman,geer,nussbaum}
\printbibliography
\autocite{sigfridsson,worman,geer,nussbaum}
\end{document}
답변3
일부 명령줄 도구를 사용하여 생성된 PDF를 사후 처리하여 인용 키를 검색하고 PDF 소스에서 바꿀 수 있습니다.
먼저 텍스트 검색 및 대체(예: pdftk
.
압축되지 않은 PDF에서 링크는 다음과 같습니다.
3 0 obj
<<
/Border [0 0 1]
/Subtype /Link
/H /I
/Type /Annot
/C [0 1 0]
/Rect [169.08 653.748 176.054 665.704]
/A
<<
/D (cite.0@secretbibkey)
/S /GoTo
>>
>>
endobj
해당 부분은 더 아래에 있습니다.
34 0 obj
<<
/Names [(Doc-Start) 22 0 R (cite.0@secretbibkey) 21 0 R (page.1) 14 0 R (section*.1) 18 0 R]
/Limits [(Doc-Start) (section*.1)]
>>
endobj
이제 grep
패턴의 소스를 확보 /D (cite.0@[some key])
하고 핵심 부분만 저장할 수 있습니다.
그런 다음 모든 키를 반복하여 체크섬 md5
(각 키에 대해 고유하다고 합리적으로 예상할 수 있음)과 같은 대체 키를 생성할 수 있습니다.
다음으로 를 사용하여 모든 키 발생을 대체 키로 바꿀 수 있습니다 sed
.
루프가 끝나면 PDF를 다시 압축하면 pdftk
완료됩니다.
전체 스크립트( 로 호출 bash myscript.sh mypdf.pdf
):
pdftk $1 output "raw$1" uncompress
grep -aoP "\/D \(\Kcite.0@[^\)]+(?=\))" "raw$1" | while read -r line ; do
echo $line
citehash=`echo $line|md5sum|awk '{ print $1 }'`
sed -i "s/$line/$citehash/g" "raw$1"
done
pdftk "raw$1" output $1 compress
Firefox의 결과 링크 툴팁:
추가 보너스: 링크는 여전히 작동합니다.