3

I once redefined the command \c since I need a shortcut for some formula that I use quite frequently. Unfortunately, I now need to cite a turkish author that has a \c{C} in his name. So, what I did is to save the old definition of \c into a new command \turc by using \let\turc\c. Consider the following MWE:

\documentclass{scrartcl}

\usepackage{natbib}

\let\turc\c

\renewcommand{\c}{\ensuremath{c^\pi}}

\begin{document}
    \citep{ABC}

    \bibliographystyle{plainnat}
    \bibliography{lit}
\end{document}

lit.bib:

@Book{ABC,
    Title="Test",
    Author="{\turc{C}}enk",
    Year="2015",
    Publisher="Me"
}

In the References, the name is shown correctly with the corresponding turkish character. However, in the actual reference \citep, the turkish character is replaced by the new definition of \c, i.e., by c^\pi.

I guess this has something to do with expansion problems, but I can't figure out how to solve the problem.

  • 2
    the solution is don't make redefinitions which break latex internals – David Carlisle Jan 29 '16 at 10:34
4

It is imho not a good idea to redefine such accent commands. But in your case you can make \turc robust:

\documentclass{scrartcl}

\usepackage{natbib}

\let\turc\c
\usepackage{etoolbox}
\robustify\turc

\renewcommand{\c}{\ensuremath{c^\pi}}

\begin{document}
    \citep{ABC}

    \bibliographystyle{plainnat}
    \bibliography{lit}
\end{document}

enter image description here

  • 1
    @user1742364: Just to be clear: egreg is quite right that you are asking for troubles when redefining \c and other accent commands. Quite often packages and internal code rely on the standard definition. So take my code as a workaround for one document. – Ulrike Fischer Jan 29 '16 at 12:16
2

When you do \let\turc\c you are essentially defining

\def\turc{\OT1-cmd \c \OT1\c}

Note that \OT1-cmd is a single control sequence, as well as \OT1\c; they can't ordinarily be written or used without special tricks.

Simplifying a bit, the purpose of \OT1-cmd is twofold: during normal typesetting, it ignores the following \c token and uses \OT1\c, which makes a cedilla under accent, but when writing to a file it makes LaTeX to write \c and ignore \OT1\c.

So, when \citep{ABC} is seen, LaTeX is instructed to write in the .aux file

\bibcite{ABC}{{1}{2015}{{{\c {C}}enk}}{{}}}

and indeed, the entry in the .aux file reads

\bibcite{ABC}{{1}{2015}{{{\c {C}}enk}}{{}}}

and you see what's going wrong.

Solution: don't redefine \c. You would need to check every bibliographic file to change \c into \turc and if you have a document not using c^\pi you'd end up into troubles unless you add a suitable definition of \turc that overcomes the problem.

If you love getting into troubles, here's a way for properly defining \turc:

\def\turc#1\c#2\turc{\def\turc{#1\turc#2}}
\expandafter\turc\c\turc

Note that if you eventually happen to reuse a UTF-8 encoded file where ç, Ç, ş or Ş appear, you will get c^\pi for every appearance, unless you also redefine the correspondences:

\DeclareUnicodeCharacter{00C7}{\turc C}
\DeclareUnicodeCharacter{00E7}{\c c}
\DeclareUnicodeCharacter{015E}{\c S}
\DeclareUnicodeCharacter{015F}{\c s}

Is the list of possible troubles you'd get in sufficient for understanding it's better leaving \c alone?

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.