
Bibtex 파일에 정의된 URL 태그를 잘라내고 싶습니다. 예를 들어 접두사 "mailto:"를 잘라내어 표시되지 않도록 하고 싶습니다. 그러나 하이퍼링크에는 여전히 해당 내용이 포함되어야 합니다. 다음 명령은 문서 환경에서는 작동하지만 참고문헌 항목에는 실패합니다. 특별한 보살핌이 필요한가요?
MWE:
\documentclass{scrreprt}
\usepackage{hyperref}
\usepackage{xstring}
\let\oldUrl\url
\renewcommand{\url}[1]{
\StrBehind{#1}{:}[\tempa]
\StrBefore{#1}{:}[\tempb]
\IfBeginWith{\tempb}{mailto}
{\href{#1}{\nolinkurl{\tempa}}}
{\oldUrl{#1}}
}
\usepackage[
backend=biber,
style=alphabetic
]{biblatex}
\addbibresource{test.bib}
\begin{document}
\url{mailto:[email protected]}
\nocite{*}
\printbibliography
\end{document}
Bibtex 파일:
@MANUAL{ABC,
title = {Test Title},
author = {ABC},
url = {mailto:[email protected]}
}
산출:
Note 태그에서는 작동하지만 url 태그에서는 작동하지 않습니다. 왜냐하면 note 태그에서 url 매크로가 사용되기 때문입니다(bibtex는 url 태그를 제공하지 않기 때문에 biber 엔진 대신 bibtex 엔진을 사용하여 발견됨).
@MANUAL{ABC,
title = {Test Title},
author = {ABC},
url = {mailto:[email protected]}
note = {\url{mailto:[email protected]}}
}
내 첫 번째 결론: biber는 하이퍼참조를 생성하기 위해 url 매크로를 사용하지 않지만, url 매크로 재정의에서 \IfBeginWith 매크로의 else 분기가 작동하는 이유는 무엇입니까?
답변1
xstring
설명서를 참조하십시오 3.4 Catcode and starred macros
.
매크로를 사용하려면 별표 표시된 테스트 매크로 버전을 사용해야 합니다.
\renewcommand{\url}[1]{
\StrBehind{#1}{:}[\tempa]
\StrBefore{#1}{:}[\tempb]
\IfBeginWith*{\tempb}{mailto}
{\href{#1}{\nolinkurl{\tempa}}}
{\oldUrl{#1}}
}