# Document Bibliographies with CJK and Pandoc

Very new to LaTeX and only limited exposure via pandoc,

I'm converting markdown English article that contains Japanese and Korean bibliography sources to PDF via LaTeX using pandoc, which allows the use of a LaTeX template. I very often use CJK (Chinese/Japanese/Korean) bibliography sources (bibtex files exported from Zotero and modified for CJK needs) which contain extra information such as the author and title name in the original characters, romanization and translation.

To get this to work in my workflow, I was delighted to find this question/answer, which was extremely helpful: Chicago-style citations of CJK documents (e.g. American Oriental Society): Name order; transcribed/translated titles

However, I'm not able to replicate the results shown there, with the sample provided there, using pandoc.

The main problem is that the translation of the title, the "usere" data in the bibtex bibliography, does not appear in the final conversion with pandoc.

To see what I'm seeing:

Sample Markdown file test.md:

This is a test.[@zhaoj, 22] Another test.[@li, 14]

# References


Sample Bibtex file bib.bib (taken from the StackExchange post):

@article{zhaoj,
author = {Zhao, 赵杰, Jie},
title = {Qingdai Manwen de wenzi tese ji yinyun, yinbian tedian},
usere = {Scriptual specificities of Manchu writing in the Qing period
and characteristics of phonology and sound change},
shorttitle = {Manwen de wenzi tese},
journal = {Manzu yanjiu},
volume = {102},
number = {1},
date = {2011},
pages = {7--12}}
@book{li,
author = {Li, 李无未, Wuwei and Brown, Junior, Bob and Doe, III, John},
publisher = {Shangwu yinshuguan},
title = {Riben Hanyu yinyun xue shi},
usere = {History of the study of Chinese phonology in Japan},
date = {2011}}


Sample TeX template template.tex for pandoc essentially just using the solution provided in the above link:

\documentclass{article}
\usepackage{xeCJK}
\setCJKmainfont{Kai}
\usepackage[authordate,backend=biber,bibencoding=utf8]{biblatex-chicago}

\newcommand{\ifnameaffix}[1]{%
\ifboolexpr{ test {\ifrmnum{#1}} or test {\ifinlist{#1}{\nameaffixlist}} }}

\DeclareNameFormat{labelname}{%
\ifboolexpr{ test {\ifblank{#7}} or test {\ifnameaffix{#7}} }
{\ifcase\value{uniquename}%
\usebibmacro{name:last}{#1}{#3}{#5}{#7}%
\or
\ifuseprefix
{\usebibmacro{name:first-last}{#1}{#4}{#5}{#8}}
{\usebibmacro{name:first-last}{#1}{#4}{#6}{#8}}%
\or
\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}%
\fi}%
{\ifnumequal{\value{uniquename}}{0}%
{\usebibmacro{name:cjk}{#1}{}{}}
{\usebibmacro{name:cjk}{#1}{#3}{}}}%
\usebibmacro{name:andothers}}

\DeclareNameFormat{first-last}{%
\ifboolexpr{ test {\ifblank{#7}} or test {\ifnameaffix{#7}} }
{\iffirstinits
{\usebibmacro{name:first-last}{#1}{#4}{#5}{#7}}
{\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}}}
{\usebibmacro{name:cjk}{#1}{#3}{#7}}%
\usebibmacro{name:andothers}}

\DeclareNameFormat{last-first}{%
\ifboolexpr{ test {\ifblank{#7}} or test {\ifnameaffix{#7}} }
{\iffirstinits
{\usebibmacro{name:last-first}{#1}{#4}{#5}{#7}}
{\usebibmacro{name:last-first}{#1}{#3}{#5}{#7}}}
{\usebibmacro{name:cjk}{#1}{#3}{#7}}%
\usebibmacro{name:andothers}}

\DeclareNameFormat{last-first/first-last}{%
\ifboolexpr{ test {\ifblank{#7}} or test {\ifnameaffix{#7}} }
{\ifnumequal{\value{listcount}}{1}
{\iffirstinits
{\usebibmacro{name:last-first}{#1}{#4}{#5}{#7}}
{\usebibmacro{name:last-first}{#1}{#3}{#5}{#7}}%
\ifblank{#3#5}
{}
{\usebibmacro{name:revsdelim}}}
{\iffirstinits
{\usebibmacro{name:first-last}{#1}{#4}{#5}{#7}}
{\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}}}}
{\usebibmacro{name:cjk}{#1}{#3}{#7}}%
\usebibmacro{name:andothers}}

\newbibmacro*{name:cjk}[3]{%
\usebibmacro{name:delim}{#2#3#1}%
\usebibmacro{name:hook}{#2#3#1}%
\mkbibnamelast{#1}%
\ifblank{#2}{}{\bibnamedelimd\mkbibnamefirst{#2}}%
\ifblank{#3}{}{\bibnamedelimd\mkbibnameaffix{#3}}}

\DeclareFieldFormat[book]{title}{%
\mkbibemph{#1}%

\DeclareFieldFormat{booktitle}{%
\mkbibemph{#1}%

\DeclareFieldFormat{maintitle}{%
\mkbibemph{#1}%

\DeclareFieldFormat[article]{title}{%
\iffieldundef{title}{}{\mkbibquote{#1}}%

\DeclareFieldFormat{usere}{\mkbibparens{#1}}

\begin{document}

\end{document}


And finally, the pandoc command used to make it all work:

pandoc --template=template.tex --latex-engine=xelatex test.md --biblio=bib.bib -o test.pdf


The result is almost there but

1. missing the "usere" translation of the titles,
2. unlike the output in the link above, surrounds both the romanized and original Chinese with quotation marks, and
3. appears to add an extra comma here and there:

For those of us out there writing academic articles that use Japanese, Chinese, and Korean sources, help with this would be really appreciated. I'd love to compile the suggestions made in the link above and answers here in a post to provide a tutorial for future users who have a similar situation. Thanks in advance for the help.

-
Thanks for the helpful edits Werner! –  Konrad Lawson Jun 20 '13 at 18:35
I will be ready to test the new multiscript branch of biblatex in the not too distant future and it seems you would be an ideal candidate. It should allow you to have multiple variants if the same field in the .bib so you don't have to resort to usere etc. –  PLK Jun 20 '13 at 19:53
@KonradLawson You might have better luck getting this sorted out at the pandoc DL. I'm not sure pandoc can fully support biblatex, let alone biblatex-chicago and the upcoming multiscript features of biblatex 3.0. –  Audrey Jun 20 '13 at 20:09
Would look forward to trying it @PLK, and Audrey, perhaps you are right. It was worth a try. –  Konrad Lawson Jun 21 '13 at 1:35
Konrad our policy here is that we usually don't have thanks on posts. One standard message we have is: Welcome to TeX.SX! Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. –  Andrew Swann Jun 21 '13 at 7:34