5

I am using the report class to write a thesis. Sometimes, more than one consecutive sentences refer to the same source, so instead of writing Booh \cite{source}. Baah \cite{source}. I write Booh. Baah. \cite{source}. But then, the citation reference is trailed by an enlarged space (indicating the end of a sentence) and followed by a normal one.

This way, the reader associates the citation reference to the following sentence, not the one it is standing behind.

I can suppress the enlarged space with \<space>. But how do I get the enlarged space after the citation?

Minimal example:

\documentclass{report}

\begin{document}
Hello, I am a sentence \cite{testcitation}. I am 
a sentence as well. \cite{testcitation} And me too!
\end{document}

Output:

Test output.

  • Have you tried inserting \phantom{.} after the second cite instruction? – Mico Sep 11 '15 at 10:19
  • Didn't know that command yet, thank you. :-) Unfortunately, this produces a too large space as it puts in an invisible dot as well. – hepfi Sep 11 '15 at 10:39
  • 1
    +1 for a question particularly well asked by a relatively new visitor. – Ethan Bolker Sep 11 '15 at 12:15
4

I'm under the impression that your readers won't understand what the citation after the period refers to. This said, here's how you can do:

\documentclass{report}
\usepackage{xpatch}

\makeatletter
\xpretocmd{\cite}{\leavevmode\spacefactor@remember}{}{}
\xapptocmd{\@citex}{\spacefactor@reset}{}{}
\newcommand{\spacefactor@remember}{%
  \ifdim\lastskip>\z@\unskip~\fi
  \xdef\spacefactor@value{\the\spacefactor}%
  \spacefactor\@m
}
\newcommand{\spacefactor@reset}{\spacefactor=\spacefactor@value\relax}
\makeatother

\begin{document}

\xspaceskip=20pt % just to show the extended spaces more clearly

Hello, I am a sentence \cite{testcitation}. I am 
a sentence as well. \cite{testcitation} And me too!

\end{document}

The setting to \xspaceskip is just to mark more clearly the end-of-sentence spaces.

enter image description here

  • Wow, this is just awesome, and I do not understand a single word between ...letter and ...other! ;) Unfortunately, this only works as long as I do not use biblatex -- as soon as I add the line \usepackage[backend=bibtex, urldate=comp, style=numeric-comp, sorting=nyt]{biblatex}, it stops working. So biblatex plays around with the cite command, right? :-( – hepfi Sep 11 '15 at 11:25
  • @hepfi That was fundamental information: with biblatex different workarounds are needed, because it does change \cite. – egreg Sep 11 '15 at 11:39
  • I am very sorry about this, I forgot to mention it when stripping down the example to be as minimal as possible. :-( Would it be easier if I just built myself a wrapper command around \cite? – hepfi Sep 11 '15 at 11:51
  • @hepfi Sorry, but you should make a complete new question, stating precisely what bibliographic package you use and also what citation commands you're going to use and that should be affected by the behavior. – egreg Sep 11 '15 at 12:08
  • Okay, then I will do that and since your code works just remove anything biblatex-related from THIS question and accept your answer. – hepfi Sep 11 '15 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.