I am working on big book and need to ensure that all citations have a white space before them. I tried
\let\citep ~\citep
But that does not seem the right thing to do. Could you please help.
Cheers
I am working on big book and need to ensure that all citations have a white space before them. I tried
\let\citep ~\citep
But that does not seem the right thing to do. Could you please help.
Cheers
there are two things wrong with your attempt.
\let equates the specified command to the next single command. even though it may not
look like one, ~ is in fact a command (for an unbreakable space). so you have just
defined \citep to be an unbreakable space.
even if you had used the more appropriate approach -- \renewcommand{\citep}{~\citep} --
you would have run into the problem that, without "freezing" the original meaning of
\citep, this would result in an unending loop.
a reliable approach is to define an entirely new command:
\newcommand{\mycitep}{~\citep}
here the original meaning of \citep is never compromised, and if you change your
mind, it's easy to change the definition. this also allows you to use the original
\citep if it is needed, for example, to start a sentence, where a preceding space
would be inappropriate.
As barbara explained, \let is not the right command to use. However, also the proposed solution is not very good, in my opinion.
Since \citep is provided by natbib, I'll assume it.
\documentclass{article}
\usepackage{natbib}
\usepackage{letltxmacro}
\LetLtxMacro{\ORIcitep}{\citep}
\DeclareRobustCommand{\citep}{\leavevmode\unskip~\ORIcitep}
In this way, \citep is defined to do the same as the original command, after removing a possible space before it and adding a tie instead. Without \unskip, an input like
word~\citep{key}
would result in two spaces.
Of course it doesn't make sense to use \citep at the start of a paragraph. So my advice is not to use such a redefinition, but to ensure ~ is typed before \citep when necessary.
See When to use \LetLtxMacro? for more information about \LetLtxMacro.
\citep starts a paragraph, there's an unwanted space at the beginning.
– barbara beeton
Dec 20 '13 at 16:20
natbib. Of course the unwanted space in front of the citation is unavoidable at the start of a paragraph, which is why I wouldn't recommend such an approach. A desired space in output should have a corresponding token in input.
– egreg
Dec 20 '13 at 16:23
\usepackage{natbib} when i tested it. you had a comment in your original answer that said you "assumed" it, and for once, i was careful enough to read the whole thing. i see you've edited a warning into the answer now.)
– barbara beeton
Dec 20 '13 at 19:14
citepackage with thespaceoption (really annoying if you want to use it in context where the sapce is not wanted). – daleif Dec 20 '13 at 16:13