Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to hack a new BibTeX style file based on plain.bst, in which I make it possible to display the value of a location field in the inproceedings entry type. I have started as follows:

  1. I have added location to the list of defined fields in the ENTRY block.
  2. In FUNCTION{inproceedings}, I have simply inserted the line location output right after where it prints the booktitle.

This works! However, now I would like simply to enclose the value of location in parentheses. I have tried defining a FUNCTION{format.location}, but I don't understand the BibTeX language well enough to get this right. Any suggestions for the function? And how do I call it in FUNCTION{inproceedings}?

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

A simple solution could look like:

FUNCTION {format.location}
{
  location empty$
    {}
    {"(" location * ")" *}
    if$
    output
}

The function works as follows: first of all it looks whether location has been given for the entry (location empty$). If the test fails (i.e., there is a value for location), then

  1. it puts ( on the stack,
  2. it puts location on the stack,
  3. * concatenates the last two elements on the stack and puts the outcome on the stack. So after this step we have (<location>
  4. puts ) on the stack
  5. * concatenates the last two elements on the stack and puts the outcome on the stack. So after this step we have (<location>)

The last step output check the current state, and includes the appropriate punctuation.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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