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 defined a @STRING in my .bib file as follows:

@STRING{mytext = {Last accessed: }}

This is an entry in the bibliography.

@ARTICLE{knuth:1974,
  author = {Knuth, Donald E.},
  title = {{C}omputer {P}rogramming as an {A}rt},
  journal = {Communications of the ACM},
  year = {1974},
  volume = {17},
  pages = {667--673},
  number = {12},
  month = {December },
  address = {New York, NY, USA},
  publisher = {ACM Press},
  note = {Last accessed: 09/20/12}
}

I want to use mytext as a template so I can easily change it. The note field however contains more then the template text.
How can I use the mytext variable in the note field?

share|improve this question
2  
have you tried note = mytext? –  Kurt Sep 20 '12 at 0:30
1  
It should be what @Kurt said, look here for more: artis.imag.fr/~Xavier.Decoret/resources/xdkbibtex/… –  pythonista Sep 20 '12 at 0:31
    
No. Because of the braces the variable name is interpreted as text. –  JJD Sep 20 '12 at 0:38
    
@JJD -- I revised my answer in light of your revised question. –  jon Sep 20 '12 at 14:24

2 Answers 2

up vote 5 down vote accepted

I'd do this:

@string{mytext = "This is the text"}

and then in the .bib entry:

@ARTICLE{knuth:1974,
  author = {Knuth, Donald E.},
  title = {{C}omputer {P}rogramming as an {A}rt},
  journal = {Communications of the ACM},
  year = {1974},
  volume = {17},
  pages = {667--673},
  number = {12},
  month = {December },
  address = {New York, NY, USA},
  publisher = {ACM Press},
  note = mytext
}

However, this won't work if the note field contains more than just the @string text. Instead you could use @preamble (if you want to keep such commands in your .bib file):

@preamble{ "\newcommand{\mytext}{Last accessed:}" }

@ARTICLE{knuth:1974,
  author = {Knuth, Donald E.},
  title = {{C}omputer {P}rogramming as an {A}rt},
  journal = {Communications of the ACM},
  year = {1974},
  volume = {17},
  pages = {667--673},
  number = {12},
  month = {December },
  address = {New York, NY, USA},
  publisher = {ACM Press},
  note = {\mytext{} 09/20/12}
}

For further details, one can always turn to 'Tame the BeaST' by Nicholas Markey: texdoc ttb.

share|improve this answer
    
Sorry. I admit my question was not formulated very well. I edited it. –  JJD Sep 20 '12 at 7:33
    
Perfect. Thank you! –  JJD Sep 21 '12 at 2:24

You can concatenate strings in a bib file with the number sign, #, but only if the strings were surrounded with double-quotes (instead of curly braces).

@STRING{mytext = "Last accessed: "}

@ARTICLE{ key,
  ...
  note = mytext # "09/20/12"
}

See: http://www.bibtex.org/Format/

share|improve this answer
    
Welcome to TeX.SX! –  Papiro Jun 12 '13 at 21:17

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.