3

I'm using BibLaTeX with biber and the authortitle style and I want to omit the "p." when citing an entry in my .bib-file BUT ONLY for entries with a non-empty shorthand field. I managed to do so by changing the postnote bibmacro in the following way:

\renewbibmacro*{postnote}{%
  \iffieldundef{postnote}
    {}
    {\setunit{\postnotedelim}%
     \iffieldundef{shorthand}
       {\printfield{postnote}}
       {\DeclareFieldFormat{postnote}{##1}%
        \printfield{postnote}}}}

This seems to work. But if I do it like this: \DeclareFieldFormat{postnote}{#1} I get an error message. Why is that the case? What is the difference between {#1} and {##1}?

Here is the MWE:

\documentclass{article}

\usepackage[style=authortitle,backend=biber, firstfull=true]{biblatex}

\renewbibmacro*{postnote}{%
  \iffieldundef{postnote}
    {}
    {\setunit{\postnotedelim}%
     \iffieldundef{shorthand}
       {\printfield{postnote}}
       {\DeclareFieldFormat{postnote}{##1}%
        \printfield{postnote}}}}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}

@Book{A1,
  Title                    = {Title1},
  Author                   = {AuthorA},
  Year                     = {1900},
  Shorthand                = {GuI}
}

@Book{B2,
  Title                    = {Title2},
  Author                   = {AuthorB},
  Year                     = {1900}
}

@Book{C2,
  Title                    = {Title2},
  Author                   = {AuthorC},
  Year                     = {1900}
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}

"Some citation of a shorthand title"\parencite[][34]{A1}

"Some citation of the same shorthand title in a footnote"\footcite[][34]{A1}

"Some citation of the same title from another page"\footcite[][70]{A1}

"Some citation of a non-shorthand title"\footcite[][12]{B2}

"Some citation of the same non-shorthand title from another page"\footcite[][15]{B2}

"Some citation of the same non-shorthand title from another author"\footcite[][15]{C2}

\printshorthands

\printbibliography

\end{document}
3
  • 1
    The normal syntax would be \DeclareFieldFormat{postnote}{#1}, but since this code is inside a macro definition (\renewbibmacro) you have to double the #. See tex.stackexchange.com/questions/42463/…
    – egreg
    Mar 15, 2015 at 21:12
  • Thank you! I thought, that there has to be an answer out there some where already, but I didn't find it. I should have tried other search terms. Maybe the question is still useful for someone trying to acomplish something similar.
    – Wamseln
    Mar 15, 2015 at 22:06
  • Well, I'm supposed to be an expert in ##. ;-)
    – egreg
    Mar 15, 2015 at 22:11

0

Browse other questions tagged .