4

In a document I would like to denote some citations by a special citation mark, for example by adding an asterisk to the citation number. I am using the article document class and the unsrturl bibliography style, together with the cite package using the superscript option. Ideally I would also like to be able to add a note at the beginning of the bibliography section that describes the meaning of the asterisk. I am using bibtex to build the bibliography.

This is what I would like to achieve:

enter image description here

It does not matter wether the special citations would be marked by an entry in the .bib file or by using a special version of the \cite command.

This question seems to contain a solution to this problem but it seems to be specific to a bibliography style. I also do not know if using the cite package would require a different solution.

My latex file has the following general structure:

\documentclass{article}
\usepackage[superscript,biblabel]{cite} 
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
 @article{citation1, TITLE = {A regular citation}}
 @article{citation2, TITLE = {A special citation}}
\end{filecontents}

\begin{document}
In the main text there is a citation~\cite{citation1} and a special citation~\cite{citation2}.

\bibliographystyle{unsrturl}  
\bibliography{\jobname}
\end{document}

which gives

enter image description here

Where do I go from here?


Update

As an ugly workaround I have come up with the following (partial) solution: I define a special \bibitem command that replaces the label (inspired by this answer) and redefine \refname to squeeze the extra line of text under the References heading:

\documentclass{article}
\usepackage[superscript,biblabel]{cite} 

\newcommand{\mybibitem}[1]{\stepcounter{enumiv} \bibitem[{\arabic{enumiv}*}]{#1}}

\renewcommand{\refname}{References

\noindent{\normalsize\rmfamily\mdseries {Note: Special citations are marked with an asterisk.}}
}

\begin{document}
In the main text there is a citation~\cite{citation1} and a special citation~\cite{citation2}.

\begin{thebibliography}{999}
\bibitem{citation1} A regular citation.
\mybibitem{citation2} A special citation.
\end{thebibliography}

\end{document}

which gives

enter image description here

This is getting close to what I want, but there are (at least) two problems:

  1. I have to convert the \bibitem to \mybibitem in the .bbl for the special citations by hand, which is not ideal but workable for now.
  2. The label of the special citation (2*) seems to be left-justified, rather than right-justified, which does not work for me because I have long list of references and therefore a rather wide column reserved for the labels. I have tried to right-justify the label using \hfill but that did not work. Does anyone have any suggestions on how to fix the alignment of those labels?
  • 2
    Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – DG' Jul 8 '18 at 19:02
  • @DG' I didn't include a MWE because I don't quite know where to start. I have added a basic template of the structure of my latex file that I hope will be helpful. – user8153 Jul 8 '18 at 19:28
  • are you open to biblatex or do you have to use cite? – DG' Jul 8 '18 at 20:20
  • I would prefer a solution based on cite and bibtex. – user8153 Jul 8 '18 at 20:43
  • 1
    That being said, a solution based on a different package (biblatex or natbib?) would also be helpful as long as it supports superscript numerical labels and does not require any changes to the .bib file. – user8153 Jul 8 '18 at 20:53
6
+50

With biblatex that is fairly simple.

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
 @article{citation1, TITLE = {A regular citation}}
 @article{citation2, TITLE = {A special citation}, keywords={special}}
\end{filecontents}
\usepackage[backend=biber, style=numeric, autocite=superscript, sorting=none]{biblatex}
\addbibresource{\jobname.bib}

\DeclareFieldFormat{labelnumber}{%
  #1%
  \ifkeyword{special}{*}{}%
}

\defbibnote{astnote}{Special citations are marked with an asterisk.}

\begin{document}
In the main text there is a citation~\autocite{citation1} and a special citation~\autocite{citation2}.

\printbibliography[prenote=astnote]
\end{document}

In this example, special entries are marked as such using the special keyword in the .bib file. If you prefer a more dynamic approach, you can use categories.

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
 @article{citation1, TITLE = {A regular citation}}
 @article{citation2, TITLE = {A special citation}}
\end{filecontents}
\usepackage[backend=biber, style=numeric, autocite=superscript, sorting=none]{biblatex}
\addbibresource{\jobname.bib}

\DeclareBibliographyCategory{special}

\DeclareFieldFormat{labelnumber}{%
  #1%
  \ifcategory{special}{*}{}%
}

\addtocategory{special}{citation2}

\defbibnote{astnote}{Special citations are marked with an asterisk.}

\begin{document}
In the main text there is a citation~\autocite{citation1} and a special citation~\autocite{citation2}.

\printbibliography[prenote=astnote]
\end{document}

Naturally you could combine the two

\DeclareFieldFormat{labelnumber}{%
  #1%
  \ifboolexpr{test {\ifkeyword{special}}
              or test {\ifcategory{special}}}
    {*}{}%
}

It would also be possible to use a special cite command, but I strongly prefer the two methods shown here. When you cite, you should not have to worry whether or not a reference is special or not.

enter image description here


Since biblatex is different from BibTeX-based bibliography and citation management there are going to be some differences. Have a look at bibtex vs. biber and biblatex vs. natbib and What to do to switch to biblatex? for a comparison of the systems and general advice on switching to biblatex. You will also want to use Biber, so Biblatex with Biber: Configuring my editor to avoid undefined citations might be worth a read.

In general a .bib file for BibTeX can also be used for biblatex, though biblatex can benefit from using certain fields that are not available for most BibTeX styles (remember: the .bst file ultimately decides which fields are supported and what exactly they mean and even though there is wide consensus among .bst files for many common fields, you can't always be sure that all styles make exactly the same thing from your data).

biblatex's numeric standard style does not exactly look like unsrturl/unsrt. biblatex-trad's trad-unsrt would probably be a closer match. But if you are OK with the general output that style=numeric gives (give or take a few simple modifications, Guidelines for customizing biblatex styles) I would not bother with biblatex-trad and stick with style=numeric. (I think I'm allowed to say that being the current maintainer of biblatex-trad.)


Here is a BibTeX solution. It requires hacking the .bst file as well as fiddling with internal macros of thebibliography.

To hack the .bst file you can either get the ready-made unsrturl-special from https://gist.github.com/moewew/727b429da91f9453639c0ec2fbdc17c2 (where you can also find the diff to the unmodified unsrturl.bst) or follow the steps below

  1. Locate unsrturl.bst on your machine for example by typing kpsewhich unsrturl.bst, failing that download it from http://mirrors.ctan.org/biblio/bibtex/contrib/urlbst/unsrturl.bst
  2. Copy the file to a place where LaTeX can find it (https://texfaq.org/FAQ-inst-wlcf), the directory of your document will do just fine, and rename it to unsrturl-special.bst, say. Note that the license of unsrt.bst on which unsrturl.bst is based requires you to change the name of the file if you modify it.
  3. Open unsrturl-special.bst and insert a header with the new file name and the current date
  4. Add special to the list of known fields in ENTRY (around line 55)
  5. Replace the entire FUNCTION {output.bibitem.original} with

    FUNCTION {output.bibitem.original} % urlbst (renamed from output.bibitem, so it can be wrapped below)
    { newline$
      "\bibitem" write$
      special empty$
        'skip$
        { "[" special * "]" * write$ }
      if$
      "{" write$
      cite$ write$
      "}" write$
      newline$
      ""
      before.all 'output.state :=
    }
    

    The block starting from special empty$ to if$ is new.

  6. Replace FUNCTION {longest.label.pass} with

    FUNCTION {longest.label.pass}
    { number.label int.to.str$
      special empty$
        'skip$
        { special * }
      if$
      'label :=
      number.label #1 + 'number.label :=
      label width$ longest.label.width >
        { label 'longest.label :=
          label width$ 'longest.label.width :=
        }
        'skip$
      if$
    }
    

    The block starting from special empty$ to if$ is new.

  7. Save the file.

The diff is

--- unsrturl.bst    2011-07-20 12:00:29.000000000 +0200
+++ unsrturl-special.bst    2018-07-10 09:21:13.297153700 +0200
@@ -1,3 +1,10 @@
+%%%%% unsrturl-special (2018-07-10)
+%%%%% unsrturl with support for marking special entries with an arbitrary
+%%%%% marker
+%%%%% The marker is given verbatim in the `special' field
+%%%%%
+%%%%% Original copyright notices follow
+
 %%% Modification of BibTeX style file /usr/local/texlive/2009/texmf-dist/bibtex/bst/base/unsrt.bst
 %%% ... by urlbst, version 0.7 (marked with "% urlbst")
 %%% See <http://purl.org/nxg/dist/urlbst>
@@ -46,6 +53,7 @@
     pubmed % urlbst
     url % urlbst
     lastchecked % urlbst
+    special
   }
   {}
   { label }
@@ -251,7 +259,12 @@

 FUNCTION {output.bibitem.original} % urlbst (renamed from output.bibitem, so it can be wrapped below)
 { newline$
-  "\bibitem{" write$
+  "\bibitem" write$
+  special empty$
+    'skip$
+    { "[" special * "]" * write$ }
+  if$
+  "{" write$
   cite$ write$
   "}" write$
   newline$
@@ -1270,7 +1283,12 @@
 }

 FUNCTION {longest.label.pass}
-{ number.label int.to.str$ 'label :=
+{ number.label int.to.str$
+  special empty$
+    'skip$
+    { special * }
+  if$
+  'label :=
   number.label #1 + 'number.label :=
   label width$ longest.label.width >
     { label 'longest.label :=

In your document you now use unsrturl-special instead of unsrturl and modify an internal macro for \bibitem as shown below

\documentclass{article}
\usepackage[superscript,biblabel]{cite} 
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{citation1, TITLE = {A regular citation}}
@article{citation2, TITLE = {A special citation}, special={*}}
\end{filecontents}

\makeatletter
\let\@olbibitem\@lbibitem
\def\@lbibitem[#1]#2{%
  \stepcounter{\@listctr}%
  \@olbibitem[\the\value{\@listctr}#1]{#2}}
\makeatother

\begin{document}
In the main text there is a citation~\cite{citation1} and a special citation~\cite{citation2}.

\bibliographystyle{unsrturl-special}  
\bibliography{\jobname}
\end{document}

This requires you to add special = {*} to every bib entry you want to highlight with an asterisk. Of course you can use other special symbols there.

enter image description here

  • This is a great answer; thank you very much. I ended up making the switch to biblatex, which after some initial hiccups seems to work fine. – user8153 Jul 11 '18 at 0:15

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.