3

Below is my code

\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}

My problem is to display HREF link combined for the below

\VOLUME{26}\SEP{, }
\FPAGE{1177}\SEP{ (}
\YEAR{1996}\SEP{).}

and not in \REFDOI{} tag

But i don't want to add/Interchange extra tags/Commands in my reference structure,

Here with attached the required output,

enter image description here

Please guide, Thanks in Advance

  • Do you always have a \VOLUME...\REFDOI input? – Werner Feb 10 '15 at 6:51
3

The following redefinition of \JRNL helps track the existence of \REFDOI, and accordingly redefines \VOLUME to capture its argument(s) for placement in a hyperlink:

enter image description here

\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}
  • Yes \JRNL entries will have \VOLUME without a \REFDOI, thanks for your advice and the answer – user52124 Feb 10 '15 at 10:24
  • @user52124: I've updated my answer to address this. – Werner Feb 10 '15 at 15:28
0
\REFDOI[https://www.google.com]{%
\VOLUME{26}\SEP{, }
\FPAGE{1177}\SEP{ (}
\YEAR{1996}\SEP{). }
}
}

with

\newcommand\REFDOI[2][]{\href{#1}{#2}}

works but where and when it may break depends on your luck.

\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}

enter image description here

  • Actually i don't want to Enclose the commands inside \REFDOI, wanted to do it through definitions, the \REFdoi should stay in its same place – user52124 Feb 9 '15 at 12:31
  • I dont want to interchange my Tags as you did in \REFDOI after \VOLUME{}, is that possible, please guide me – user52124 Feb 10 '15 at 6:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.