6

My standard bibliography setup is to use bibtex in the amsalpha style. References are displayed by labels which contain a few letters related to the author followed by the two digit publication year. That is mostly fine, but occasionally when including historical references it seems a little confusing as far as dates go, e.g.

"The study of this question goes back all the way to [G20]; for a recent survey see [B21]".

Is there a way to make references from years before a certain date (say 1900) appear with all four digits and later references with the usual two digits?

So in the example above, assume that [B21] was written by Joe Bloggs in 2021 and [G20] was written by Gauss in 1720, I would want it to read:

"The study of this question goes back all the way to [G1720]; for a recent survey see [B21]".

I want to keep using amsalpha style, but would consider using a modified myamsalpha.bst file instead. (That is was chatGPT suggested, but the various lines of code it wanted me to add caused errors and the fixes caused more errors and so on. and let's just say it ended badly.)


Added: A working example.

\documentclass[12pt,reqno]{amsart}
\usepackage{amssymb,amsmath,amsfonts,amsthm}

\begin{document}

 "The study of this question goes back to~\cite{Gauss}; for a recent survey see~\cite{Bloggs}.


\bibliographystyle{amsalpha}
\bibliography{Working}

\end{document}

And the bib file:

@misc {Gauss,
    AUTHOR = {Gau\ss , Carl Friedrich},
     TITLE = {Important Stuff},
       YEAR = {1821},
 }  
    
@misc{Bloggs,
Author = {Joe Bloggs},
Title = {Notes {I} just wrote},
Year = {2021},
}
2
  • I know that you are not using OpTeX, so just for your information. OpTeX doesn't use external program for bibliography (like BibTeX, biber), all folks are done at TeX macro level. There is \_createbibmark macro with parameters year;Lastname,Othernames;NextAuthor,...\_fin so you can define \def\_createbibmark #1;#2#3\_fin{#2\ifnum#1>2000 \onlytwo#1\else #1\fi}
    – wipet
    May 18 at 5:28
  • you can probably add a key to the bib entry, but as you didn't provide any example for a test ... May 18 at 9:32

2 Answers 2

1
+100

The amsalpha.bst style rejects anything that's not a digit in the year field and takes just the last two digits.

If you don't have too many such entries, you can fix them by hand.

\begin{filecontents*}[overwrite]{\jobname.bib}
@misc {Gauss,
  author = {Gau{\ss}, Carl Friedrich},
  title = {Important Stuff},
  year = {1821},
}  
    
@misc{Bloggs,
  author = {Joe Bloggs},
  title = {Notes {I} just wrote},
  year = {2021},
}
\end{filecontents*}

\documentclass[12pt,reqno]{amsart}

\NewCommandCopy\latexbibitem\bibitem

\ExplSyntaxOn
\RenewDocumentCommand{\bibitem}{O{}m}
 {
  \lullaby_bibitem:en { \lullaby_bibitem_check:n { #1 } } { #2 }
 }

\cs_new_protected:Nn \lullaby_bibitem:nn { \latexbibitem[#1]{#2} }
\cs_generate_variant:Nn \lullaby_bibitem:nn { e }
\cs_new:Nn \lullaby_bibitem_check:n
 {
  \str_case:nnF { #1 }
   {
    {Gau21}{Gau1821}
    % other entries to fix
   }
   { #1 }
 }
\ExplSyntaxOff

\begin{document}

The study of this question goes back to~\cite{Gauss}; for a recent survey see~\cite{Bloggs}.

\bibliographystyle{amsalpha}
\bibliography{\jobname}

\end{document}

I used filecontents* just to make the example self-contained, use your .bib file for the production version.

The redefined \bibitem command checks the optional argument to be in the list of exceptions that you can fill in in the same way as I did for the Gauss paper.

enter image description here

The following modification of the code works for all releases of TeX Live from 2018. Replace

\NewCommandCopy\latexbibitem\bibitem

with

\ifdefined\NewCommandCopy
  \NewCommandCopy\latexbibitem\bibitem
\else
  \let\latexbibitem\bibitem
  \usepackage{xparse}
\fi
2
  • First report: It worked, although I don't quite understand it. Second report: It didn't work on my other computer, and I had to upgrade my LaTeX distribution (from early 2020), since "\NewCommandCopy" gave a "command not found" error. So there might be a chance my co-authors also have trouble. I'll leave it a little longer to see if anyone else has a more elementary fix but will otherwise accept this answer. Thanks!
    – Lullaby
    May 19 at 2:20
  • @Lullaby I added a variant of code in order to support older versions of LaTeX.
    – egreg
    May 19 at 9:50
1

If you switch to biblatex, you can use shorthand for the bibitems you want with full year.

This code works from TeX Live 2019 onwards.

\begin{filecontents*}[overwrite]{\jobname.bib}
@misc {Gauss,
  author = {Gau{\ss}, Carl Friedrich},
  title = {Important Stuff},
  year = {1821},
  shorthand={Gau1821},
}  
    
@misc{Bloggs,
  author = {Joe Bloggs},
  title = {Notes {I} just wrote},
  year = {2021},
}
\end{filecontents*}

\documentclass[12pt,reqno]{amsart}
\usepackage{etoolbox}
\usepackage[style=alphabetic]{biblatex}

\addbibresource{\jobname.bib}

\begin{document}

The study of this question goes back to~\cite{Gauss}; for a recent survey see~\cite{Bloggs}.

\printbibliography

\end{document}

enter image description here

2
  • Thankyou! I am constrained to using the files chosen by my coauthors but will keep this in mind for the future.
    – Lullaby
    May 24 at 17:21
  • @Lullaby You're welcome! I'm happy egreg's answer fits you.
    – CarLaTeX
    May 24 at 17:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .