6

For my PhD thesis I have to typeset the author's family name in capital letters in the citation call-out but not in the bibliography itself. So, I mean:

cite: SCHULTZ, 1971

bibliography: Schultz, T. W. (1971): Book name.

In addition, for several authors I should use hyphen, like this:

JOSHI - PETERSON, 2013

Could anybody help me how one does this? Thanks.

What I tried so far: (but I needed capital letters in cite)

\documentclass[12pt,a4paper]{report}  
\usepackage[latin1]{inputenc}  
\usepackage{amsmath}  
\usepackage{amsfonts}    
\usepackage{amssymb}  

\usepackage[authoryear]{natbib}    
\bibliographystyle{apalike}  

\begin{document}  

blablabalbal~\citealp{aas2004modelling}  

\bibliography{bibfile}    

\end{document}  
  • 2
    Welcome to TeX.SX! 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}. – Marco Daniel Feb 21 '17 at 16:17
  • 1
    As Marco Daniel said, many more information are needed. Most importantly, how do you cite: BibTeX (with or without additional citation packages like natbib) or BibLaTeX? In case of BibTeX, which bibliographystyle and can you use another one? In case of BibLaTeX, did you already redefine anything? Please post a full minimal working example containing all those crucial information. – Manuel Weinkauf Feb 21 '17 at 17:51
  • Marco Daniel and Manuel Weinkauf many thanks, I edited my question. – Panni Feb 21 '17 at 18:15
  • Well, you use apalike as your cite style. This is relevant for the formatting. You could try to find a more suitable style, or try to create one with makebst. But since you are apparently writing a report and are not bound to any particular templates, I would suggest to switch to BibLaTeX. All formatting is much more flexible and on-the-fly in this system. A solution for your particular problem could for instance be found here. – Manuel Weinkauf Feb 21 '17 at 18:41
  • 1
    @ManuelWeinkauf -- well, I made this reference for those who want to answer. It is way more sensible to answer questions that are alredy there, right? (and then mark the actual duplicates as such) – Ruben Feb 21 '17 at 20:53
4

If you want to stick with BibTeX, I suggest you proceed as follows:

  • Find the file apalike.bst in your TeX distribution, make a copy of this file, and name the copy (say) apalikeCAPS.tex. (Don't edit an original file of the TEX distribution directly.)

  • Open the tile apalikeCAPS.bst in a text editor. The program you use to edit your tex files will do fine.

  • In this file, locate the function called emphasize. (The function starts on line 200 in my copy of the bst file.)

  • After this function, insert the following code:

    FUNCTION {makeuppercase}
    { duplicate$ empty$
        { pop$ "" }
        { "\MakeUppercase{" swap$ * "}" * }
      if$
    }
    

    As you can probably guess, this function uppercases its argument.

  • Find the function format.lab.names. (It should start around line 848, allowing for the 5 or 6 new lines you created when you inserted the new function.) In this function, change the line

    s #1 "{vv~}{ll}" format.name$ 
    

    to

    s #1 "{vv~}{ll}" format.name$ makeuppercase
    

    In addition, change the line

             { " and " * s #2 "{vv~}{ll}" format.name$ * }
    

    to

             { "--" * s #2 "{vv~}{ll}" format.name$ * makeuppercase }
    

    Note that the second line has undergone two changes: " and " has been replaced with "--" (an "en-dash"), and makeuppercase has been inserted after format.name$ *.

  • Save the file apalikeCAPS.bst either in the directory that contains your main tex file or in a directory that's searched by BibTeX. If you choose the second option, be sure to also update the filaname database of your TeX distribution.

    • In your main tex file, change the directive \bibliographystyle{apalike} to \bibliographystyle{apalikeCAPS} and do a full recompile (latex-bibtex-latex-latex) to fully propagate all changes.

Happy BibTeXing!


Aside: As @MarcoDaniel has pointed out in a comment, quite a few of natbibs capabilities aren't available if apalike (or apalikeCAPS) is used as the bibliography style. For instance, the package's longnamesfirst option doesn't work, and neither do the "starred" variants (\citet*, \citep*, etc) of the citation-generating macros. (More precisely, \citet* produces the same output as \citet does, etc.)


The output of a full MWE:

enter image description here

\RequirePackage{filecontents}
\begin{filecontents}{mybib.bib}
@misc{uno,
  author = "Anna Author",
  title  = "Thoughts",
  year   = 3001,
}
@misc{due,
  author = "Anne Author and Bertha Buthor",
  title  = "Further Thoughts",
  year   = 3002,
}
@misc{tre,
  author = "Anne Author and Bertha Buthor and Carla Cuthor",
  title  = "Final Thoughts",
  year   = 3003,
}
\end{filecontents}

\documentclass{article}
\usepackage[authoryear]{natbib}
\bibliographystyle{apalikeCAPS}

\begin{document}
\citep{uno}, \citep{due}, \citep{tre}
\bibliography{mybib}
\end{document}
  • I think you should mention that the style apalike can't use the advantages of natbib -- It's the next limitation. – Marco Daniel Feb 21 '17 at 20:13
  • @MarcoDaniel - Are you referring to the fact that apalike can only generate authoryear-type citation call-outs, and thus that loading natbib with the option numbers (or superscripts...) will generate a crash? For sure, natbib's \citet, \citep, \citealt, \citealp, \citeauthor and \citeyear macros all work fine with the apalike bibliography style. – Mico Feb 21 '17 at 20:18
  • @MarcoDaniel - Welcome back, by the way! – Mico Feb 21 '17 at 20:20
  • 2
    @Panni - In the file apalikeCAPS.bst, find the function format.names; it should start around line 216. Scroll down about 15 lines to a line that reads { " and " * t * }. In this line, replace " and " with "--". Save the file and rerun BibTeX and LaTeX. – Mico Feb 22 '17 at 15:18
  • 1
    @Panni - I'm really not sure I understand your formatting requirements. For sure, I've never written a paper in which the authors' names in the bibliography had to be separated by en-dashes. Please go back to the function format.names, find the line that says { ", " * t * }, and in that line replace ", " with "--". – Mico Feb 22 '17 at 15:54
7

If you switch to BibLaTeX, you will be able to do both things very easily:

\documentclass[12pt,a4paper]{report}
\usepackage[latin1]{inputenc}

\usepackage[style=authoryear, backend=biber]{biblatex}
\addbibresource{bibfile.bib}

%Authors in upper case in citations, normal font in bibliography
\renewcommand{\mkbibnamefamily}[1]{\ifcitation{\MakeUppercase{#1}}{#1}}
\renewcommand{\mkbibnameprefix}[1]{\ifcitation{\MakeUppercase{#1}}{#1}}

%Hyphen between author names
\renewcommand{\multinamedelim}{\space--\space}
\renewcommand{\finalnamedelim}{\space--\space}

\begin{document}  

blablabalbal \textcite{aas2004modelling}

\printbibliography

\end{document}

EDIT: Author name formatting streamlined. Thanks to Marco Daniel for pointing out the existence of the ifcitation command.

  • 2
    You can use the test \ifcitation -- \renewcommand{\mkbibnamefamily}[1]{\ifcitation{\MakeUppercase{#1}}{#1}} \renewcommand{\mkbibnameprefix}[1]{\ifcitation{\MakeUppercase{#1}}{#1}} – Marco Daniel Feb 21 '17 at 20:12
  • Even though the version with \ifcitation may be more compact (in a way) it is not at all unusual to use \AtBeginBibliography to reset commands for the bibliography. – moewe Feb 24 '17 at 17:23
5

You can do it with macros, without changing apalike.bst.

\begin{filecontents*}{\jobname.bib}
@article{one,
  author={A. Uthor},
  title={Title},
  journal={Journal},
  year=2001,
}
@article{two,
  author={W. Riter and P. Enman},
  title={Title},
  journal={Journal},
  year=2002,
}
@article{three,
  author={A. Uthor and W. Riter and P. Enman},
  title={Title},
  journal={Journal},
  year=2003,
}
\end{filecontents*}

\documentclass{article}
\usepackage{etoolbox}
\usepackage{expl3}
\usepackage[authoryear]{natbib}
\bibliographystyle{apalike}

\ExplSyntaxOn
\cs_new_protected:Npn \panniuppercase #1
  {
   \tl_set:Nx #1 { \tl_upper_case:V #1 }
  }
\cs_generate_variant:Nn \tl_upper_case:n { V }
\cs_new_protected:Npn \pannihyphen #1 #2
 {
  \tl_gset:Nn #1 #2
  \tl_greplace_once:Nnn #1 { ~ AND ~ } { - }
  \tl_gset:Nx #1 { { \exp_not:V #1 } }
 }
\ExplSyntaxOff

\makeatletter
\patchcmd{\NAT@split}
  {\gdef\NAT@name}
  {\pannihyphen\NAT@name}
  {}{}
\patchcmd{\NAT@parse}
  {\aftergroup}
  {\panniuppercase\NAT@temp\aftergroup}
  {}{\ddt}
\makeatother


\begin{document}

\citet{one} \citet{two} \citet{three}

\bibliography{\jobname}

\end{document}

The filecontents* environment is just for making the example self-contained. Use your own bib file.

enter image description here

  • Great solution. I have a short question. You are replacing a global definition by \gdef with \tl_set:Nx. I had thought that \tl_gsetis the correct choice. – Marco Daniel Feb 21 '17 at 21:05
  • @MarcoDaniel You're right. Probably the \gdef is not really needed, but… – egreg Feb 21 '17 at 21:09

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.