0

absolute Latex beginner here with a question: I changed the \autocite command to add in-text citation in the following format: (Author year: [page number]) (for example: (Dylan 1967: 5)). I used the following code in main.tex:

\DeclareCiteCommand{\autocite}
  {\usebibmacro{prenote}}
  {\printtext[parens]{\printnames{labelname} \printfield{year}\addcolon\addspace\usebibmacro{postnote}}}
  {\multicitedelim}

Here's the issue. After each citation (they do work miraculously) Latex does a line break which I do not want. Is there either a way to get rid of the line break or a smarter way in general to achieve my desired in-text citation?

Thank you!

1
  • Hi, which biblatex style do you use? In general, its better to provide a compilable MWE instead of just some code snippets. In your code it seems that on some occasions you're missing some braces and on other there are too many which don't have a matching counterpart. This might cause your troubles. But right now I'm not able to test it.
    – lukeflo
    Sep 13 at 13:50

1 Answer 1

1

Since its not fully clear which biblatex style you're using, here is a simple solution for style=authoryear. But it may also work with other styles, depending on the definition of some macros.

Here a full working MWE with updated code:

\documentclass{article}

\begin{filecontents*}[overwrite]{bibfile.bib}
  @article{bouche_2006,
  author    = {Bouche, Thierry},
  journal   = {Tugboat},
  title     = {A {pdfLaTeX}-based automated journal production system},
  year      = {2006},
  number    = {1},
  pages     = {45--50},
  volume    = {27},
}
\end{filecontents*}

\usepackage[style=authoryear]{biblatex}
\addbibresource{bibfile.bib}

% code snippet for you to copy:
\DeclareDelimFormat{postnotedelim}{\addcolon\space}
\DeclareFieldFormat{postnote}{#1}
\DeclareCiteCommand{\autocite}[\mkbibparens]
  {\usebibmacro{prenote}}
  {\printnames{labelname}\space\printfield{year}}
  {\multicitedelim}
  {\usebibmacro{postnote}}
% end snippet

\begin{document}
test \autocite[227]{bouche_2006}. test

\printbibliography
\end{document}

As you can see, there is no linebreak after the citation. If it still occurs in your document when you use my adapted snippet, we need additional informations about your code.

If you still want the page prefix p. in front of the given pagenumber, just uncomment the DeclareFieldFormat line.

2
  • Beautiful answer, thank you very much! I only changed {\printnames{labelname}\space\printfield{year}} to {\printnames{labelname}\space\printfield{year}:\space} to add a colon and a space. Sep 15 at 13:52
  • Thanks. You mean, you changed it, to receive the colon and space before the postnote? That should normally be accomplished by \DeclareDelimFormat{postnotedelim}{\addcolon\space}, which offers the advantage that the colon and the space are only typeset if the postnote is used in the particular \cite command.
    – lukeflo
    Sep 15 at 13:59

You must log in to answer this question.

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