BibTeX and Chinese names
As wonderful as BibTeX is, it's always bothered me that it formats non-initial names as "First Last" even when they're Chinese names (or Japanese, etc., but most of the citations I use are Chinese), which customarily put the surname first. "But how would BibTeX know that the name's Chinese?" you ask. Actually, it's nothing magical, I stick the actual characters into my bibliography file. E.g., Author = {Ikeda, Takumi \TC{池田巧}}, where \TC means "use a traditional chinese font" (defined in my XeLaTeX file). If only I could get BibTeX to check if the name includes that string, and handle it differently....
WARNING: the following code is in a language that uses Reverse Polish notation. Viewers who might be offended by RPN should not view this program.
As it turns out, the fix is quite simple. Just add a function to your .bst file:
STRINGS{text}
FUNCTION{cjk.contains}
{ 'text :=
#0
{ text empty$ not }
{ text #1 #3 substring$ duplicate$ "\SC" = swap$ "\TC" = or
{ pop$
#1
"" 'text :=
}
{
text #2 global.max$ substring$ 'text :=
}
if$
}
while$
}
And then, where the file calls format.name$, you can add an if statement to see if it contains Chinese or not. So, this:
s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$
would turn into this:
s nameptr
s nameptr "{ff}" format.name$ cjk.contains
{ "{vv~}{ll}{~ff}{, jj}" }
{ "{ff~}{vv~}{ll}{, jj}" }
if$
format.name$
Neat, huh? By the way, BibTeX doesn't define the boolean function not, so if your .bst file doesn't define it you'll have to add that in. For a down-and-dirty guide to BibTeX, check out this link:
http://www.lsv.ens-cachan.fr/~markey/BibTeX/doc/ttb_en.pdf
Or more generally, this page:

Leave a comment