9

I try to use biblatex (to be customized) with Hungarian babel language definition files. The babel language for Hungarian is called magyar (means: Hungarian).

I am writing a text in which I cite English and Hungarian articles also. I managed to create magyar.lbx based on english.lbx to be able to use Hungarian text in the bibliography with the help of specifying hyphenation = {magyar} in bib files, and it works like a charm.

The problem is that I would like to modify the format of bibliography further, as in Hungarian the last and first name are in reversed order, e.g. in Hungarian Jules, Verne is written like: Verne Jules.

This is implemented in huplain.bst for using with BibTeX (with the option specifying huname =1), but unfortunatelly it does not work with author-year format citation (e.g. natbib or babelbib), that is why I had to look for other solutions. It looks like for me, that modifying biblatex's code is the easiest way.

Does anyone have idea about how could I put some conditional statements maybe to \DeclareNameFormat{labelname} to be able to list Hungarian names in reverse order without a comma between last and first name? I hope it can be done. Thanks for reading!


Editing on the bases of @michal.h21's answer:

I have made a summary in Hungarian language about the results of this topic based on @michal.h21's answer and comments. You can find it here.

Most important features do work, some lesser parts are not so sexy, but will work it out somehow. Any extra comments are welcome!

6
  • 3
    In one bibliography I'd pick one style, either first name first or last name first. You don't mess with other parts of a bibliography on an entry-by-entry basis, after all. (Imagine changing the labels or the field order!)
    – Joseph Wright
    Jan 16, 2011 at 21:32
  • @Joseph Wright: you are right, and I am giving an upvote for your comment, that is what I think too. But I have to work out this customization written above, as it is a formal requirement of my Ph.D. thesis. Do not ask me why :) As it is done in huplain.bst in the nfmt functions I hope it is possible in biblatex also. Well, the best would be to use huplain.bst with author-year citation format after all, as it takes care of every localization issues.
    – daroczig
    Jan 16, 2011 at 21:52
  • @daroczig. I see, that is odd but I guess you will have to get on with it. Might be one to ask Philipp Lehman, as it might need some biblatex internal stuff. I don't remember seeing anything about generic language-selective functions.
    – Joseph Wright
    Jan 16, 2011 at 21:57
  • @Joseph Wright: I hope there might be a simpler solution, e.g. defining NameFormat in the lbx files - what did not succeed although.
    – daroczig
    Jan 16, 2011 at 22:35
  • 1
    @daroczig: Providing updates to your question will naturally bump it to the top of the site, so there's no need to label the question as "UPDATED". I hope you don't mind that I have removed the additional label. (At any rate, my edit bumped your question one more time. ;-))
    – lockstep
    Jan 17, 2011 at 20:48

2 Answers 2

10

you can try to define formatting command in \DeclareBibliographyExtras section in lbx file.

so in magyar.lbx

\protected\def\nameprint#1#2{#1\space#2}

and in english.lbx

\protected\def\nameprint#1#2{#2\addcomma\space#1}

and in bbx define name format:

\DeclareNameFormat{default}{%
   \nameprint{#1}{#3}
   ..call macro for punctation
   ..call macro for and others
 }


Edit: I was in hurry yesterday, so didn't post complete example.

DeclareNameFormat is command, which accepts 8 parameters. they are:

  • #1 The last names. If a name consists of a single part only (for example, ‘Aristotle’), this part will be treated as the last name.
  • #2 The last names, given as initials.
  • #3 The first names. This argument also includes all middle names.
  • #4 The first names, given as initials.
  • #5 The name prefixes, for example von, van, of, da, de, del, della, etc. Note that name prefixes are referred to as the ‘von part’ of the name in the BibTeX documentation.
  • #6 The name prefixes, given as initials.
  • #7 The name aYxes, for example ‘junior’, ‘senior’, ‘der Jüngere’, ‘der Ältere’, etc. Note that name aYxes are referred to as the ‘junior part’ of the name in the BibTeX documentation.
  • #8 The name aYxes, given as initials.

This command is called on every name in list, if number of authors is smaller than \value{maxnames}. If you have 8 authors and maxnames is set to 5, it will print only authors up to \value{minnames}, I have this value set to 3.

We call command \nameprint with full last and first name. If you need other parts of name use some parameter from list above.

Then we have to print punctuation after every author. I do that with folowning macro:

\newbibmacro{names:separator}{%
  \ifthenelse{\value{listcount}<\value{liststop}}%
  {\addsemicolon\addspace}%
  {}%
 }

This macro prints semicolon and space after every author except last one. If you want other punctuation than semicolon, you can replace it with some other punctuation command. Their list is on the page 155 of biblatex manual. Or you can directly print char with \printtext command.

My andothers macro look like this:

\newbibmacro*{names:andothers}{%
 \ifboolexpr{%
   test {\ifnumequal{\value{listcount}}{\value{liststop}}}%
   and%
   test \ifmorenames%
 }{\bibsstring{andothers}}%
 {}%
}

We don't have to add punctuation after andothers, because it is printed automatically with next \newunit command in your \DeclareBibliographyDriver.

So my \DeclareNameFormat now looks this way:

\DeclareNameFormat{default}{%
 \nameprint{#1}{#3}
 \usebibmacro{names:separator}%
 \usebibmacro{names:andothers}%
 }

Now I see, that my first version of \nameprint was incorrect. Magyar version should probably be:

 \protected\def\nameprint#1#2{#2\space#1}

And English:

\protected\def\nameprint#1#2{#1\addcomma\space#2}

You have to define this macro for every language you use in your bibliography, otherwise you will get error message about undefined command.


Another edit based on comments below this post:

you must create bbx and cbx file. For example:

huglain.bbx

\ProvidesFile{hugplain.bbx}

\DeclareLanguageMapping{magyar}{magyar}
\RequireBibliographyStyle{authoryear}

\renewcommand*{\finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\bibsstring{and}\space}

\newbibmacro{names:separator}{%
  \ifthenelse{\value{listcount}<\value{liststop}}%
  {\addcomma\addspace}%
  {}%
 }

\newbibmacro{names:separator2}{%
  \ifthenelse{\value{listcount}<\value{liststop}}%
  {\addspace}%
  {}%
 }

\newbibmacro*{names:andothers}{%
 \ifboolexpr{%
   test {\ifnumequal{\value{listcount}}{\value{liststop}}}%
   and%
   test \ifmorenames%
 }{\bibsstring{andothers}\addcomma}%
 {}%
}

%\DeclareNameFormat{default}{%
% \nameprint{#1}{#3}
% \usebibmacro{names:separator}%
% \usebibmacro{names:andothers}%
% }

\DeclareNameFormat{sortname}{%
 \nameprint{#1}{#3}
 \usebibmacro{names:separator}%
 \usebibmacro{names:andothers}%
 }



\endinput

notice line

    \DeclareLanguageMapping{magyar}{magyar}

this is loading of your magyar.lbx file. In your current version, this file is not used at all, so in your citation there is "and" before last name instead of "és"

hugplain.cbx is rather simple

\ProvidesFile{hugplain.cbx}
\RequireCitationStyle{authoryear}
\endinput

In your tex file delete all biblatex macros and call babel with \usepackage[english,magyar]{babel}. Last language is the main language of document.

at top of file magyar.lbx, right below line \PorvidesFile... add lines

\InheritBibliographyExtras{english}
\InheritBibliographyStrings{english}

and you have error in bibliography strings, replace

bibliography     = {{Felhasznált\addspaceirodalom}{Felhasznált\addspaceirodalom}},

with

bibliography     = {{Felhasznált\addspace{}irodalom}{Felhasznált\addspace{}irodalom}},

and finally, you should add hyphenation fields even to english publications in your bib files, unless you want to have citation like Berk, Kriegler, és Ylvisaker

14
  • @michal.h21: thank you very much! I tried your suggestion, but unfortunately it seems to me that defining \nameprint does not work. Or I might have missed something in pasting the \DeclareNameFormat part, as I did not know where to paste it (I tried in several bbx files without any effect), and included in the header of my main tex file. It does not shows the sign of knowing about the \nameprint definition per different language lbx files. I think I have really missed something, could you help me further?
    – daroczig
    Jan 17, 2011 at 0:02
  • @michal.h21: Wow, with \DeclareNameFormat{sortname} your solution seems to work! I have to fine-tune it, and will be back for upvote & accepting your asnwer. Thanks!
    – daroczig
    Jan 17, 2011 at 0:27
  • 1
    it could be maybe best, if you can post somewhere your tex, bbx, cbx and magyar.lbx files, it is difficult to guess what is hapenning
    – michal.h21
    Jan 17, 2011 at 15:25
  • 1
    and I can't see any reason, why there is "and" in citation, this term should be localised as command \finalnamedelim call \bibstring{and}
    – michal.h21
    Jan 17, 2011 at 21:55
  • 1
    I edited my answer, problem was, that your localization file wasn't loaded
    – michal.h21
    Jan 17, 2011 at 22:33
3

I faced a similar problem, but with citing papers with Hungarian and non-Hungarian co-authors. Therefore, the hyphenation approach was of little use for me. Instead, I opted for (mis)using the junior part of the name. The result could probably be used to scare small children. :-)

Hungarian authors may be written as Vezetéknév, HUN, Keresztnév, whereas non-Hungarian authors remain as usual.

magyar.bbx is

\ProvidesFile{magyar.bbx}

\DeclareLanguageMapping{magyar}{magyar}
\RequireBibliographyStyle{authoryear-comp}

\def\@magyarbbx@hun{HUN}

\DeclareNameFormat{sortname}{%
  \begingroup%
    \edef\juniorpart{#7}%
    \ifx\juniorpart\@magyarbbx@hun%
      % Hungarian name
      \usebibmacro{name:first-last}{#3}{#1}{#5}{\relax}%
    \else%
      % English name
      \ifnum\value{listcount}=1\relax%
        \usebibmacro{name:last-first}{#1}{#3}{#5}{#7}%
      \else%
        \usebibmacro{name:first-last}{#1}{#3}{#5}{#7}%
      \fi%
    \fi%
  \endgroup%
}

\endinput

while magyar.cbx is simply

\ProvidesFile{magyar.cbx}
\RequireCitationStyle{authoryear-comp}
\endinput

The reason that the citation style needs no modification is that the junior part is only printed in authoryear citations if two authors have different junior parts but otherwise equal first/last name.

Of course, this approach fails if an actual junior part is needed for a Hungarian author, but usually that is not the case. I suppose one could implement a more sophisticated check and a real citation style.

2
  • Thanks, that's useful indeed. Meanwhile I dropped LaTeX for markdown while writing my thesis, as most prof. required Word docs, where Pandoc can do a great job with it's great reference/citation features.
    – daroczig
    Aug 6, 2012 at 18:59
  • Are you still using/working on this? Maybe you can have a look at tex.stackexchange.com/q/428749/35864
    – moewe
    Apr 27, 2018 at 6:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .