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'm trying to learn biblatex and have small problem. according of czech style for academic writings, some fields in bibliographic record, like volume, edition or issue, should be in language of source document, others, like pages, should be in language current document is written in. so:

KRSKOVÁ, L.; HILSKÁ, I.; KOPECKÁ, P. aj. Molekulární diagnostika maligních lymfomů řady B : detekce klonality a stručný přehled problematiky s vlastními výsledky. Časopis lékařů českých. 2004, roč. 143, č. 3, s. 191-194. ISSN 0008- 7335.

vs.

BROWMAN, Howard I.; STERGIOU Konstantinos I. Factors and indices are one thing, deciding who is scholarly, why they are scholarly, and the relative value of their scholarship is something else entirely. Ethics in science and environmental politics. June 2008, vol 8, no. 1, s. 1-3. ISSN 1863-5415.

I have no problem to get localized strings with \bibsstring, but how I can take string from main language? I tried something like


\DeclareFieldFormat*{pages}{#1}
\newbibmacro{pagecount}{%
  \iffieldundef{pages}{}
    {\selectlanguage{czech}\bibsstring{pages}\addnbspace\printfield{pages}}}

..
\DeclareBibliographyDriver{article}{%
..
\usebibmacro{pagecount}

and it works, but I think there must be some more elegant way than hardcode language into style.

Does exist some command to switch to main language, or can I use some variable? I have found \blx@languagename, but it holds only language of current record.


Edit

My solution bellow has little problem. It add spaces to output.

SMITH, Alan; NEWMAN, Paul; PINKY, John   aj. Some title. 3rd ed. 
  New York : MIT Press, 1991. 332  s.

there should be of course just one space before aj. and s.

biblatex redefines babel macro \bbl@set@language, so probably some problem lies there.

If we have following sample

\documentclass[a4paper,10pt]{article}
\usepackage[english,czech]{babel}
%\usepackage[backend=biber,style=apa,sorting=nyt,babel=other]{biblatex}
\makeatletter 
   \newcommand\mainlanguage{\expandafter\bbl@set@language\expandafter{\bbl@main@language}}%
\newcommand\ml{[\bbl@main@language{}--\languagename]}
\makeatother
\begin{document}
\ttfamily
(\mainlanguage) \ml 
(\selectlanguage{czech}) \ml 
(\selectlanguage{english}) \ml  
\end{document}

result is:

() [czech--czech]() [czech--czech]() [czech--english]

if we uncomment \usepackage[...]{biblatex}:

(   ) [czech--czech](   ) [czech--czech]( ) [czech--english]

On base of another question I made macro for discard command output:

\newlength{\trashlength}
\def\ignoreoutput#1{\globaldefs=1 \settowidth{\trashlength}{#1}}

it discards spaces, but references are now without italics and dashes.

Question So, is there some other way how to discard spaces? Or is it better to find the source of spaces in biblatex.sty? (I tried to do that, but with no success)

share|improve this question
    
If I compile your example with style=authoryear instead of style=apa, I don't get additional spaces. Check the documentation of biblatex-apa -- you should use the command \DeclareLanguageMapping. Maybe this will also solve your spacing problem. –  lockstep Jan 19 '11 at 15:19
    
I get bad spaces even with <emph>style=authoryear</emph>. In fact I encountered with this problem while working on my attempt of iso690 style - github.com/michal-h21/biblatex-iso690, this code was just illustration of same problem. In this style I am using \DeclareLanguageMapping –  michal.h21 Jan 19 '11 at 15:33

1 Answer 1

up vote 2 down vote accepted

I finally have found solution in babel docs:


\newcommand\mainlanguage{\expandafter\bbl@set@language\expandafter{\bbl@main@language}}}

\newbibmacro{pagecount}{%
  \iffieldundef{pages}{}
    {\mainlanguage\addnbspace\printfield{pages}}}


Edit: maybe it is a dirty hack and inefficient, but this version don't add unwanted spaces:

\newlength{\trashlength}  
\newcommand\mainlanguage{\expandafter\bbl@set@language\expandafter{\bbl@main@language}{\settowidth{\trashlength}\expandafter\bbl@set@language\expandafter{\bbl@main@language}}\kern-\trashlength}}%
share|improve this answer

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.