0

I am quite a new user of Natlib package with some basic knowledge of Latex.

I have defined a custom new function \Mycite to obtain an hybrid citation with Authors (Year) [Number]. The rest of my paper use only numbered citation.

I can't find out how to remove the white space after the function \Mycite. This produces also some trouble if citation is placed at the end of a line, causing hence a line break between the citation and punctuation.

Could someone explain me how to remove the white space after the right bracket?

\@ seems not working and with penalty option I am not very confident.

Thanks in advance Chris

Screenshot of output pdf

Here a minimal example of code

\documentclass{article}

\usepackage{lipsum}
\usepackage[%
square, 
numbers, 
comma, 
sort, 
sort&compress
]{natbib} % enable use of two citation mode(both author–year and numerical citations)

\usepackage{hyperref}

% enable to cite the author and year between brackets
\newcommand\Mycite[1]{%
\citeauthor{#1}~(\citeyear{#1})~\citep{#1}\@
}

\newcommand\MycitewN[1]{% with Numbers 
\citeauthor{#1}~(\citeyear{#1})\@
}

\begin{document}
\citep{doe-1999}. \lipsum[23] \Mycite{doe-1999}. \lipsum[23] \MycitewN{doe-1999}. \lipsum[23]
\citep{thul-2010}. \lipsum[23] \Mycite{thul-2010}. \lipsum[23] \MycitewN{thul-2010}. \lipsum[23] 
\bibliographystyle{unsrtnat}
\bibliography{mybib}
\end{document}

and the code for mybib.bib

@article{doe-1999,
author="John Doe",
title="Some Paper",
journal="Some Journal",
volume=1, number=1, pages={1--10}, year=1999}

@article{thul-2010,
author="Thul, Patrick and House, K. and Tuttle, C.",
title="Some other Paper",
journal="Some Journal",
volume=1, number=1, pages={1--10}, year=2010}
ChrisDE
  • 103
  • 2
    You need a % at the end of the \citeauthor lines in your two macro definitions. Inside a macro definition (and elsewhere), a line feed is interpreted as a space, unless commented out with a %. See http://tex.stackexchange.com/questions/7453/what-is-the-use-of-percent-signs-at-the-end-of-lines – Steven B. Segletes Sep 11 '14 at 18:06
  • Thanks a lot, the solution is correct. I replace the code and its works fine \newcommand\Mycite[1]{% \citeauthor{#1}~(\citeyear{#1})~\citep{#1}@% }

    \newcommand\MycitewN[1]{% with Numbers \citeauthor{#1}~(\citeyear{#1})@% }

    – ChrisDE Sep 11 '14 at 18:22

0 Answers0