下面是我的代码
\documentclass{article}
\usepackage{hyperref}
\hypersetup{colorlinks,%
citecolor=white,%
filecolor=blue,%
linkcolor=blue,%
urlcolor=blue,
}
\newcommand\JRNL[1]{#1}
\newcommand\AUGRP[1]{{#1}}
\newcommand\AUTHOR[1]{#1}
\newcommand\SNM[1]{#1}
\newcommand\INITS[1]{#1}
\newcommand\SEP[1]{#1\ignorespaces}
\newcommand\ATITLE[1]{#1}
\newcommand\JTITLE[1]{{\em #1}}
\newcommand\VOLUME[1]{#1}
\newcommand\YEAR[1]{#1}
\newcommand\FPAGE[1]{#1}
\newcommand\LPAGE[1]{#1}
\newcommand\REFDOI[1]{\href{#1}{#1}}
\begin{document}
\begin{thebibliography}{99}
\JRNL{
\bibitem{bib1}
\AUGRP{\AUTHOR{\INITS{L.}\SEP{ }\SNM{Snselfin}}}\SEP{. }
\ATITLE{Simple Text title.}\SEP{ }
\JTITLE{Regfionfal swqfq}\SEP{ }
\VOLUME{26}\SEP{, }
\FPAGE{1177}\SEP{ (}
\YEAR{1996}\SEP{). }
\REFDOI{https://www.google.com}\SEP{.}
}
\end{thebibliography}
\end{document}
我的问题是显示下面的 HREF 链接组合
\VOLUME{26}\SEP{, }
\FPAGE{1177}\SEP{ (}
\YEAR{1996}\SEP{).}
并且不在 \REFDOI{} 标签中
但我不想在我的参考结构中添加/交换额外的标签/命令,
这里附有所需的输出,
请指导,提前致谢
答案1
以下的重新定义\JRNL
有助于追踪的存在\REFDOI
,并相应地重新定义\VOLUME
以捕获其参数以便放置在超链接中:
\documentclass{article}
\usepackage{hyperref,etoolbox}
\hypersetup{colorlinks,%
citecolor=white,%
filecolor=blue,%
linkcolor=blue,%
urlcolor=blue,
}
\newcommand\JRNL[1]{%
\def\JRNLarg{#1}% Store argument in \JRNLarg
% Check whether \JNRLarg contains \REFDOI or not
\patchcmd{\JRNLarg}{\REFDOI}{\REFDOI}{% \REFDOI found
\gdef\VOLUME##1##2\REFDOI##3\SEP##4{{%
\def\YEAR####1\SEP####2{####1\SEP{####2}\unskip}%
\href{##3}{##1##2}%
}}%
}{% \REFDOI not found
\gdef\VOLUME##1{##1}%
}%
#1% Process argument
}
\newcommand\AUGRP[1]{{#1}}
\newcommand\AUTHOR[1]{#1}
\newcommand\SNM[1]{#1}
\newcommand\INITS[1]{#1}
\newcommand\SEP[1]{#1\ignorespaces}
\newcommand\ATITLE[1]{#1}
\newcommand\JTITLE[1]{\emph{#1}}
\newcommand\YEAR[1]{#1}
\newcommand\FPAGE[1]{#1}
\newcommand\LPAGE[1]{#1}
\newcommand\REFDOI[1]{\href{#1}{#1}}
\begin{document}
\begin{thebibliography}{99}
\JRNL{
\bibitem{bib1}
\AUGRP{\AUTHOR{\INITS{L.}\SEP{ }\SNM{Snselfin}}}\SEP{. }
\ATITLE{Simple Text title.}\SEP{ }
\JTITLE{Regfionfal swqfq}\SEP{ }
\VOLUME{26}\SEP{, }
\FPAGE{1177}\SEP{ (}
\YEAR{1996}\SEP{). }
\REFDOI{https://www.google.com}\SEP{.}
}
\JRNL{
\bibitem{bib2}
\AUGRP{\AUTHOR{\INITS{L.}\SEP{ }\SNM{Snselfin}}}\SEP{. }
\ATITLE{Simple Text title.}\SEP{ }
\JTITLE{Regfionfal swqfq}\SEP{ }
\VOLUME{26}\SEP{, }
\FPAGE{1177}\SEP{.}
\REFDOI{https://www.google.com}\SEP{.}
}
\JRNL{
\bibitem{bib3}
\AUGRP{\AUTHOR{\INITS{L.}\SEP{ }\SNM{Snselfin}}}\SEP{. }
\ATITLE{Simple Text title.}\SEP{ }
\JTITLE{Regfionfal swqfq}\SEP{ }
\FPAGE{1177}\SEP{. }
\REFDOI{https://www.google.com}\SEP{.}
}
\JRNL{
\bibitem{bib3}
\AUGRP{\AUTHOR{\INITS{L.}\SEP{ }\SNM{Snselfin}}}\SEP{. }
\ATITLE{Simple Text title.}\SEP{ }
\JTITLE{Regfionfal swqfq}\SEP{ }
\VOLUME{26}\SEP{, }
\FPAGE{1177}\SEP{.}
}
\end{thebibliography}
\end{document}
答案2
\REFDOI[https://www.google.com]{%
\VOLUME{26}\SEP{, }
\FPAGE{1177}\SEP{ (}
\YEAR{1996}\SEP{). }
}
}
和
\newcommand\REFDOI[2][]{\href{#1}{#2}}
可以工作,但是何时何地会损坏取决于你的运气。
\documentclass{article}
\usepackage{hyperref}
\hypersetup{colorlinks,%
citecolor=white,%
filecolor=blue,%
linkcolor=blue,%
urlcolor=blue,
}
\newcommand\JRNL[1]{#1}
\newcommand\AUGRP[1]{{#1}}
\newcommand\AUTHOR[1]{#1}
\newcommand\SNM[1]{#1}
\newcommand\INITS[1]{#1}
\newcommand\SEP[1]{#1\ignorespaces}
\newcommand\ATITLE[1]{#1}
\newcommand\JTITLE[1]{{\em #1}}
\newcommand\VOLUME[1]{#1}
\newcommand\YEAR[1]{#1}
\newcommand\FPAGE[1]{#1}
\newcommand\LPAGE[1]{#1}
\newcommand\REFDOI[2][]{\href{#1}{#2}}
\begin{document}
\begin{thebibliography}{99}
\JRNL{
\bibitem{bib1}
\AUGRP{\AUTHOR{\INITS{L.}\SEP{ }\SNM{Snselfin}}}\SEP{. }
\ATITLE{Simple Text title.}\SEP{ }
\JTITLE{Regfionfal swqfq}\SEP{ }
\REFDOI[https://www.google.com]{%
\VOLUME{26}\SEP{, }
\FPAGE{1177}\SEP{ (}
\YEAR{1996}\SEP{). }
}
}
\end{thebibliography}
\end{document}