3

I'd like to know if it is possible to add white spaces around the dash sign in page range in bibliography list.

That's what I have:

S. 1234-1235

That's what I want to have:

S. 1234 - 1235

In my bib-file the pages tag includes white spaces:

pages = {1234 -- 1235}

That is my minimal bib file:

@article{IJAMT,
         author        = {Author},
         title         = {Title},
         journaltitle  = {Journal},
         year          = {2016},
         volume        = {69},
         number        = {9 -- 12},
         pages         = {2315 -- 2321},
         label         = {REF}

And here is my minimal example:

\documentclass[a4paper,11pt,oneside,ngerman]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[style=alphabetic,bibencoding=utf8,hyperref=true,sorting=anyt,    natbib=true, backend=biber]{biblatex}

% Own Style for Articles
\DeclareBibliographyDriver{article}{%
  \printnames{author}:\newunit%
  \printfield{title}.\newunit%
  \printfield{journaltitle}{ }\printfield{volume}{ }%
  (\printfield{year}){ }\printfield{number},\newunit%
  \printfield{pages}%
  \finentry}

\bibliography{literature/bib}

\begin{document}
  \cite{IJAMT}
  \newpage
  \printbibliography
\end{document}
moewe
  • 175,683
Micha
  • 31
  • Welcome to TeX.SE. To give a correct answer without a complete MWE is difficult. I guess, you could enter the page range in your BibTeX-file as 1234~-~1235 although I am convinced, that it is typographically incorrect. – Jan Dec 23 '16 at 10:23
  • That does not work. – Micha Dec 23 '16 at 10:27
  • 1
    Please give us more details and save us from having to type everything on our own. – Jan Dec 23 '16 at 10:29
  • jan is asking about an MWE/MWEB.That is the easiest and most efficient way to tell us how exactly you create your bibliography - a solution will most likely depend on the packages and styles you use. – moewe Dec 23 '16 at 10:42
  • Do you use biblatex as your tagging suggests or BibTeX as the title suggests? – moewe Dec 23 '16 at 10:47
  • I use biblatex. I changed the title. – Micha Dec 23 '16 at 10:50
  • Note that your redefinition of the @article driver is a bit rough. You should never have a literal : or ( in the driver definition. – moewe Dec 23 '16 at 11:01
  • What would be a better way to do this? – Micha Dec 23 '16 at 12:28
  • I have edited my answer to include an alternative to your redefinition of the @article driver. – moewe Dec 23 '16 at 14:01

1 Answers1

6

We just need to redefine \bibrangedash to add the space

\DefineBibliographyExtras{english}{%
  \renewrobustcmd*{\bibrangedash}{\addspace\textendash\space}}

Since \bibrangedash is a language-specific command, we need to redefine it within \DefineBibliographyExtras{<lang>} where <lang> is your document language.

Instead of \addspace\textendash\space you could also use thin spaces and prevent a line break before the dash by using

\addnbthinspace\textendash\penalty\hyphenpenalty\addthinspace

instead.


BTW: You instead of redefining your @article driver in the way you did, you could use

\renewcommand*{\labelnamepunct}{\addcolon\space}

\renewbibmacro*{journal+issuetitle}{%
  \usebibmacro{journal}%
  \setunit*{\addspace}%
  \iffieldundef{series}
    {}
    {\newunit
     \printfield{series}%
     \setunit{\addspace}}%
  \printfield{volume}%
  \setunit{\addspace}%
  \usebibmacro{issue+date}%
  \setunit{\addspace}%
  \printfield{number}%
  \setunit{\addcomma\space}%
  \printfield{eid}
  \setunit{\addcolon\space}%
  \usebibmacro{issue}%
  \newunit}

to achieve a similar thing. Plus maybe Suppress “In:” biblatex. You should not have literal punctuation in your driver, always use \setunit and friends together with \addcomma and friends or put the formatting into \DeclareFieldFormat.

moewe
  • 175,683
  • 2
    Doesn't this add feasible break points before and after the dash? – egreg Dec 23 '16 at 10:58
  • @egreg So it does. Do you think that is undesirable? Would you prefer \renewrobustcmd*{\bibrangedash}{\addnbspace\textendash\addnbspace}? – moewe Dec 23 '16 at 11:00
  • If a space must be, I'd prefer it thinner and not flexible; breaking before the dash is obviously not a choice, after it might help in tough situation. – egreg Dec 23 '16 at 11:28
  • What is the main advantage using \renewbibmacro*{journal+issuetitle} instead redefining @article ? – Micha Jan 06 '17 at 06:29
  • @Micha The standard @article driver contains many things that can be controlled via options, your redefinition kills almost all or these options and uses some other crude techniques such as hard-coded punctuation. For what you want it is only necessary to redefine journal+issuetitle (this macro is used in the driver for @article) since that is the only part of the article driver that needs to be changed. – moewe Jan 06 '17 at 14:30