[Tex/LaTex] Environment for changing citations in tables

bibliographiescite-packagecitingtables

I am making citations with non-superscript numbers in square brackets, just as:

enter image description here

with code:

y de los tres momentos de inercia \cite{Spec}. Para el caso de una

In the preamble I have declared:

\usepackage[longnamesfirst]{natbib}
\setcitestyle{square}

And then, inside the document:

\begin{document}

\bibliographystyle{ieeetr}
\bibliography{./bibliography}

Where I have a bibliography.bib file in the same folder.

In tables, the non-superscript citation is not a good solution:

enter image description here

Code:

\begin{table}
\begin{tabular}{lllll}
\cline{2-3}
\multicolumn{1}{l|}{}   & \multicolumn{1}{l|}{CD}   & \multicolumn{1}{l|}{EF}   &  &  \\ \cline{1-3}
\multicolumn{1}{|l|}{a} & \multicolumn{1}{l|}{5.45\cite{Spec1,Spec2}} &      \multicolumn{1}{l|}{25.8 \cite{Spec3}} &  &  \\ \cline{1-3}
\multicolumn{1}{|l|}{b} & \multicolumn{1}{l|}{44.2} & \multicolumn{1}{l|}{3.21 \cite{Spec4,Spec5}} &  &  \\ \cline{1-3}
                    &                           &                           &  &
\end{tabular}
\end{table}

It is preferred to make those citations with superscript square brackets.

Would it be possible to make a special environment in every table in order to indicate that the citations should appear in superscript square brackets ?

Here is my preamble:

\documentclass[12pt,a4paper,twoside,openany]{report}
\usepackage[left=2.5cm,top=2.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\parindent 1 true cm
\usepackage{graphicx}
\usepackage{eufrak}
\usepackage[spanish]{babel}
\usepackage[latin1]{inputenc}  
\usepackage[T1]{fontenc}
\usepackage{times}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{float}
\usepackage{color}
\usepackage[longnamesfirst,super]{natbib} 
\setcitestyle{square}
\usepackage{fancyhdr}   
\pagestyle{fancy}                                        
\renewcommand{\chaptermark}[1]{\markboth{\thechapter .\ #1}{}}             
\renewcommand{\sectionmark}[1]{\markright{\thesection .\ #1}{}}
\lhead{\nouppercase}
\rhead{\nouppercase}
\fancyhead[LE]{{\sf \leftmark}}                             
\fancyhead[RE]{}
\fancyhead[RO]{{\sf \rightmark}}
\fancyhead[LO]{}                                                
\fancyfoot[LE,RO]{\thepage}                                           
\fancyfoot[CE,CO]{}                                                         
\renewcommand{\headrulewidth}{0.0pt}                                
\renewcommand{\baselinestretch}{1.25}
\usepackage{adjustbox}
\usepackage{enumerate}
\usepackage{courier}
\usepackage{caption}
\usepackage[version=3]{mhchem}
\usepackage{rotating}
\usepackage[percent]{overpic}
\captionsetup{font={small}}
\begin{document}

Thanks.

Best Answer

You can redefine \cite in the table environment; with etoolbox it's quite easy.

\documentclass[12pt,a4paper,twoside,openany]{report}
\usepackage[left=2.5cm,top=2.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage{graphicx}
\usepackage{eufrak}
\usepackage[spanish]{babel}
\usepackage[latin1]{inputenc}  
\usepackage[T1]{fontenc}
\usepackage{times}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{float}
\usepackage{color}
\usepackage[numbers]{natbib} 
\setcitestyle{square}
\usepackage{fancyhdr}   
\pagestyle{fancy}                                        
\renewcommand{\chaptermark}[1]{\markboth{\thechapter .\ #1}{}}             
\renewcommand{\sectionmark}[1]{\markright{\thesection .\ #1}{}}
\lhead{\nouppercase}
\rhead{\nouppercase}
\fancyhead[LE]{{\sf \leftmark}}                             
\fancyhead[RE]{}
\fancyhead[RO]{{\sf \rightmark}}
\fancyhead[LO]{}                                                
\fancyfoot[LE,RO]{\thepage}                                           
\fancyfoot[CE,CO]{}                                                         
\renewcommand{\headrulewidth}{0.0pt}                                
\renewcommand{\baselinestretch}{1.25}
\usepackage{adjustbox}
\usepackage{enumerate}
\usepackage{courier}
\usepackage{caption}
\usepackage[version=3]{mhchem}
\usepackage{rotating}
\usepackage[percent]{overpic}
\captionsetup{font={small}}
\usepackage{letltxmacro,etoolbox,booktabs}

\LetLtxMacro{\originalcite}{\cite}
\def\tablecite#1#{%
  \def\pretablecite{#1}%
  \tableciteaux}
\def\tableciteaux#1{%
  \textsuperscript{\expandafter\originalcite\pretablecite{#1}}%
}
\AtBeginEnvironment{table}{\let\cite\tablecite}

\begin{document}

A citation \cite{article-full}

\begin{table}
\begin{tabular}{ll}
\toprule
Something & Foo \\
\midrule
a\cite{whole-journal,booklet-full} & b\cite{manual-full}  \\
\bottomrule
\end{tabular}
\end{table}

\bibliographystyle{ieeetr}
\bibliography{xampl}

\end{document}

Of course, longnamesfirst is meaningless for numeric citations.

enter image description here

Related Question