1

It is one of my school's rule to use '~' instead of '--' to combine page numebers in the bibiograhy citation list. I tried to modify the original .bst style file, but I am new to biblatex's grammer. I figured out that the critical codes that define the page numbers default behavior look like this:

   FUNCTION {n.dashify}
{ 't :=
  ""
    { t empty$ not }
    { t #1 #1 substring$ "-" =
    { t #1 #2 substring$ "--" = not
        { "--" *
          t #2 global.max$ substring$ 't :=
        }
        {   { t #1 #1 substring$ "-" = }
        { "-" *
          t #2 global.max$ substring$ 't :=
        }
          while$
        }
      if$
    }
    { t #1 #1 substring$ *
      t #2 global.max$ substring$ 't :=
    }
      if$
    }
  while$
}

With these codes, the original compiled latex file looks like this: original effect

But I want the page numbers to be connected by the "~" symbol instead of '--', like this: wanted effect I would very appreciate it if anybody can offer some help.

2 Answers 2

1

Here you are:

FUNCTION { n.dashify }
{
  't :=
  ""
    { t empty.or.unknown not }
    {
      t #1 #1 substring$ "-" =
        {
          t #1 #2 substring$ "--" = not
            { "\textasciitilde{}" *
              t #2 global.max$ substring$ 't :=
            }
            {
              { t #1 #1 substring$ "-" = }
              {
                t #2 global.max$ substring$ 't :=
              }
              while$
              "\textasciitilde{}" t * 't :=
            }
          if$
        }
        {
          t #1 #1 substring$ *
          t #2 global.max$ substring$ 't :=
        }
      if$
    }
  while$
}

The unnamed bst language uses the reverse Polish notation, so it is not easy to understand the logic of the the program. Basically if we see a lone -, we substitute it for \textasciitilde{}, and if we see a string of -, we delete them and put \textasciitilde{} instead.

1
  • Finally got the problem solved by adopting to your code! Truely appreciate your help, sir!
    – nujabse
    Feb 29, 2020 at 7:11
0

Do a global search and replace in the .bib file ?

I think an easier way is to avoid changing any .bst style files and just do a global search and replace in any .bib files you have. While this is easier I don't think it is a great idea in case there are any --- (em dash) in there, so do any replacement with care. (Also I am unsure if this will line-break nicely, and doubt it).

enter image description here

\begin{filecontents}{references.bib}
@article{author00,
title = {{A Title}},
author= {Person, Some},
journal={SIAM Journal on Something},
volume={10},
number={1},
pages={25\textasciitilde2587},
year={2011},
publisher={SIAM}
}

@article{author01,
title = {{A Title}},
author= {Person, Some},
journal={SIAM Journal on Something},
volume={10},
number={1},
pages={25$\sim$2587},
year={2011},
publisher={SIAM}
}
\end{filecontents}

\documentclass[11pt, a4paper, twoside]{extarticle}
\usepackage[numbers, sort&compress]{natbib} % Nice references.
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\bibliographystyle{unsrtnat}
\begin{document}
\noindent
\citet{author00} and \citet{author01}.
\bibliography{references}
\end{document}

You must log in to answer this question.

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