Hi,
I would like to change the behavior of the \cite command in the text. I do not change at all how the references from e.g. bibtex are listed in the bibliography, I want to change the appearence of \cite in the text.
An example: I put a \cite{ref1} into my text, which will become later e.g.
text blah [1] blah text
now I want to redefine/newdefine/change cite (i.e. create a new command citeb) that gives the same output in the text, but e.g. the content in the brackets bold, like
text blah [1] blah text
I have tried to do that with \textbf\cite{ref1}}, which does not work. Is there a way to define such a modified cite command, that prints out the cite key in bold, italics etc??
Thanks
Alex
Text Formatting ⇒ Change behavior of cite command in text
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Change behavior of cite command in text
Requires the redefinition of a helper macro from the LaTeX kernel.
Unwanted side effects cannot be ruled out.
Thorsten
Code: Select all
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\makeatletter
\def\@citex[#1]#2{\leavevmode
\let\@citea\@empty
\@cite{\bfseries\@for\@citeb:=#2\do
{\@citea\def\@citea{,\penalty\@m\ }%
\edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
\if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
\@ifundefined{b@\@citeb}{\hbox{\reset@font\bfseries ?}%
\G@refundefinedtrue
\@latex@warning
{Citation `\@citeb' on page \thepage \space undefined}}%
{\@cite@ofmt{\csname b@\@citeb\endcsname}}}}{#1}}
\makeatother
\begin{document}
\cite{key}
\begin{thebibliography}{9}
\bibitem{key} Bibliography Item
\end{thebibliography}
\end{document}
Probably. But since this would mean a lot of work and I'm short in time I can't offer this solution at the moment.alex170872 wrote:[…] Is there a way to define such a modified cite command, that prints out the cite key in bold, italics etc?? […]
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 6
- Joined: Fri Jan 14, 2011 4:13 pm
Re: Change behavior of cite command in text
Hi,
thanks for the help, but the definition of citex given in the example does not seem to work at all. When compiling latex it tells me
Undefined control sequence.
It looks like latex does not find a definition for citeb (even if I rename \def\@citex[#1]#2{\leavevmode to \def\@citeb[#1]#2{\leavevmode) and independent of whether I include those fontenc and inputenc packages.
Is this example supposed to work, or just an example of how to do things? I myself have absolutely no idea how to work with any of these '@' variables or how to change some internal 'things'.
So if someone has a working example of how to create a citeb command to cite something in bold, while leaving the cite command to work as normal*!) that would be great.
Thanks
Alex
thanks for the help, but the definition of citex given in the example does not seem to work at all. When compiling latex it tells me
Undefined control sequence.
It looks like latex does not find a definition for citeb (even if I rename \def\@citex[#1]#2{\leavevmode to \def\@citeb[#1]#2{\leavevmode) and independent of whether I include those fontenc and inputenc packages.
Is this example supposed to work, or just an example of how to do things? I myself have absolutely no idea how to work with any of these '@' variables or how to change some internal 'things'.
So if someone has a working example of how to create a citeb command to cite something in bold, while leaving the cite command to work as normal*!) that would be great.
Thanks
Alex
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Change behavior of cite command in text
The example has been tested and works as provided. Did you try to compile it as is?alex170872 wrote:[…] Is this example supposed to work, or just an example of how to do things? […]
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 6
- Joined: Fri Jan 14, 2011 4:13 pm
Re: Change behavior of cite command in text
Oh I see, this formalism changes cite, but does not introduce a new command.
Maybe I have not bee very clear in my first post, but what I would like to have is a command 'citeb' to cite something in bold, while having the normal 'cite' command as usual to cite other refs just as before.
Is that possible to implement like this?
Thanks
Alex
Maybe I have not bee very clear in my first post, but what I would like to have is a command 'citeb' to cite something in bold, while having the normal 'cite' command as usual to cite other refs just as before.
Is that possible to implement like this?
Thanks
Alex