6

I'm using

\usepackage{cite}

to reference bibliography (I'm using bibtex). In general the text is in greek, but bibliography is in english. I'm using babel package, so in order to write in english you need to put your text between \selectlanguage commands, which change the language. For example, to write a reference I have to use

\selectlanguage{english}\cite{foo}\selectlanguage{greek}

because else latin characters get substituted by greek and I don't want this to happen since bibliography is in english.

So I made a little macro:

\newcommand{\citem}[1]{\selectlanguage{english}\cite{#1}\selectlanguage{greek}}

For some reason, this command adds white space before the reference. For example, if I want to reference book Blah Blah labeled as foo and write Some text (\citem{foo}), this prints out

Some text ( [Blah])

How can I make this space between the opening parenthesis and the bracket disappear?

I know for sure that the language is not the problem here, because I changed the macro to the trivial

\newcommand{\citem}[1]{\cite{#1}}

and printed

( [Βλαη])

The latin characters turned into greek, this was expected, but the space remained.

Update: Thanks to egreg, I found a way to get rid of the redundant white space before references. Macro is:

\makeatletter
\newcommand{\citem}[1]{%
  \begingroup\let\cite@adjust\@empty
  \textlatin{\cite{#1}}%
\endgroup
}

But now I can't use citem into a caption. Error is:

Argument of \@caption has an extra }.
  <inserted text>
    \par
l.261 }
  • What TeX distribution are you using? – egreg Feb 22 '14 at 21:37
  • Can you provide a minimal working example (MWE)? I think \unskip would work, but you can't be certain with a real use case. – Sean Allred Feb 22 '14 at 21:40
  • @egreg, I'm using texlive/latex. – frabala Feb 22 '14 at 22:04
  • @frabala I changed \newcommand into \DeclareRobustCommand; with it, it should work also in captions. – egreg Feb 22 '14 at 22:44
6

First of all, you don't need to use \selectlanguage twice.

The cite package works hard to avoid the citation is attached to the previous word, when normal citation style is used. Setting the citation inside parentheses is quite unusual, as there are already the square brackets to separate it from the context and the wording makes clear if the citation is parenthetical or not.

If you really need such a style, I suggest you to define differently two commands, one for parenthetical cites, one for normal ones:

\documentclass{article}
\usepackage[english,greek]{babel}
\usepackage{cite}

\makeatletter
\DeclareRobustCommand{\pcite}[1]{%
  \begingroup\let\cite@adjust\@empty
  (\textlatin{\cite{#1}})%
  \endgroup
}
\makeatother
\DeclareRobustCommand{\ncite}[1]{% cite without parentheses
  \textlatin{\cite{#1}}%
}

\begin{document}
This is in Greek \pcite{x} again Greek.

This is in Greek \ncite{x} again Greek.

\selectlanguage{english}
\begin{thebibliography}{Blah}
\bibitem[Blah]{x} Something
\end{thebibliography}
\end{document}

enter image description here

  • Can you please generalize the commands, so that more than one entry could be cited. For example \pcite{me2010,you2015}? – Roboticist Jun 10 '17 at 21:32
  • @Roboticist This uses the standard \cite command, so it does everything the original does. – egreg Jun 10 '17 at 21:58
  • The compiler throws an undefined control sequence warning as I try to pass more than one entry into \pcite command (just like as I mentioned in my previous comment)! However, it can finally return the result. – Roboticist Jun 10 '17 at 22:07
  • @Roboticist I get no error. – egreg Jun 10 '17 at 22:10
0

Insert an \unskip token right before your citation:

\newcommand\citem[1]{\selectlanguage{english}\unskip\cite{#1}\selectlanguage{greek}
  • I should note that this should work and is my knee-jerk reaction to the problem. This of course may not work considering your exact use; an MWE would help. – Sean Allred Feb 22 '14 at 21:39

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.