# Vancouver style file accuses me of popping an empty literal stack

This document (problem.tex) and bibliography (problem.bib) work as expected:

\documentclass{article}
\begin{document}
This.\cite{altman}
\bibliography{problem}{}
\bibliographystyle{plain}
\end{document}

@phdthesis{altman,
title={Districting principles and democratic representation},
author={Altman, Micah},
year={1998},
school={California Institute of Technology}
}


However, changing "plain" to "vancouver" causes this error:

You can't pop an empty literal stack for entry altman

while executing---line 1865 of file vancouver.bst

I checked in Wikipedia and the @phdthesis entry seems to have the right attributes. What is happening with the vancouver.bst and what should I do about it?

• Apparently vancouver.bst wants you to supply a type, e.g. type = {Ph.D. thesis},. Note that the exact requirements for fields may differ slightly between .bst especially for the more uncommon types. The Wikipedia page probably only refers to general guidelines or the base styles. – moewe Oct 22 '18 at 20:04
• Looking at the code I think this is undesired behaviour. There is code to guard against an empty type field, it just doesn't quite work. Anyway, the result is the same, you need a type field to avoid the error. – moewe Oct 22 '18 at 20:12
• Thank you @moewe! I see how you got there and I appreciate you looking at this for me. – Aaron Brick Oct 22 '18 at 20:24

In the code vancouver.bst has set up to deal with an empty type field there is a small mistake that causes an empty type to cause an error regardless.

That means that for vancouver.bst the type field is mandatory for @phdthesis if you want to avoid the error you get. Note that .bst files ultimately decide themselves which fields are mandatory and optional (or supported at all), so the list on Wikipedia is only informative and not guaranteed to get everything right for all styles. That said the base styles (plain.bst and friends) as well as the BibTeX documentation set out general guidelines that most styles adhere to, so the information on Wikipedia is solid, but not guaranteed to be authoritative in all cases.

The simplest way to get rid of the error is thus to provide a type field

@phdthesis{altman,
title  = {Districting principles and democratic representation},
author = {Altman, Micah},
year   = {1998},
school = {California Institute of Technology},
type   = {Ph.D. thesis},
}


But you can also modify vancouver.bst to accept type-less @phdthesis entries.

1. Locate vancouver.bst on your machine (using kpsewhich vancouver.bst). If you can't find it on your computer, get it from http://mirrors.ctan.org/biblio/bibtex/contrib/vancouver/vancouver.bst
2. Copy the file to a location where LaTeX can find it (see https://texfaq.org/FAQ-inst-wlcf, for a one-off the directory of your .tex file will do just fine) and rename the file to, say, vancouver-type.bst.
3. Open vancouver-type.bst and search for FUNCTION {format.type} (that function should be in ll. 912-918), replace the entire function with

FUNCTION {format.type}
{ type empty${ "" } { inbrackets type } %%{ add.blank "[" type * "]" * } if$
}


That is, change the second line in the definition from 'skip$ to { "" }. 4. Add a short note about the change to the top of the file, sign off with your name or initials and add the date of the change. In the end, the diff between vancouver.bst and vancouver-type.bst could look like this --- vancouver.bst 2018-10-23 08:22:27.331033600 +0200 +++ vancouver-type.bst 2018-10-23 08:41:59.679102900 +0200 @@ -1,3 +1,12 @@ +%%%% vancouver-type.bst' +%%%% modified from vancouver.bst' to allow empty type field in @phdthesis +%%%% for https://tex.stackexchange.com/q/456287/35864 +%%%% MW, 2018-10-23 +%%%% original vancouver.bst' by Folkert van der Beek +%%%% available at https://ctan.org/pkg/vancouver +%%%% +%%%% unmodified original header follows +%%%------------------------------------------------------------------ %% %% This vancouver.bst' bibliographic style file (for LaTeX/BibTeX) is %% generated with the docstrip utility and modified manually to meet the @@ -911,7 +920,7 @@ FUNCTION {format.type} { type empty$
-    'skip$+ { "" } { inbrackets type } %%{ add.blank "[" type * "]" * } if$


If you now use vancouver-type instead of vancouver in your document, you are allowed to leave the type field empty.