Zitierbefehl nur in Tabellenumgebung neu definieren

Zitierbefehl nur in Tabellenumgebung neu definieren

Ich erstelle Zitate für einen Abschlussbericht mit dem NatBib-Paket:

\usepackage[authoryear,sort,round]{natbib}
\bibliographystyle{apa}

Die Zitate sollen im Text nach Autor und Jahr in Klammern aufgeführt und auch sortiert werden, was für mich perfekt funktioniert.

Das Problem besteht darin, dass ich mit der Tabellenumgebung sehr große Spalten habe, die eine große Anzahl von Zitaten enthalten. Wenn ich den Autorjahresstil in den Tabellen beibehalte, ist es schwierig, die Tabellenbreite an die Textbreite anzupassen, selbst wenn ich benutzerdefinierte Spalten verwende.

%ltxtable configuration
\newcolumntype{L}{>{\RaggedRight\arraybackslash}X} % flush-left, while allowing hyphenation
\newcolumntype{C}{>{\Centering\arraybackslash}X} % centered, while allowing hyphenation
\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash}p{#1}}

Ich muss den Befehl „cite“ neu definieren, damit die Nummerierung in Klammern erfolgt und nicht nur im Autorenstil, sondern nur innerhalb der Tabellenumgebung. Außerdem möchte ich, dass die Klammern hochgestellt sind. Ich habe bereits eine Lösung dafür gefunden, aber sie erfolgt immer im Autorenjahrstil:

\usepackage{letltxmacro}

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

So sieht mein Dokument (der mindestens erforderliche Code) aus:

\documentclass[12pt,fleqn,a4paper]{book} % Default font size and left-justified equations

\usepackage{etoolbox}

% Bibliography
\usepackage[authoryear,sort,round]{natbib}
\bibliographystyle{apa}%this one order the list of references whereas abbrvnat is the elsevier thing;

\usepackage{afterpage}
\usepackage{capt-of}% or use the larger `caption` package
\usepackage{textcomp} % display ' apostrophe
\usepackage{dirtytalk} % access \say
\usepackage{longtable} %access longtable
\usepackage{lscape} %access landscape
\usepackage{pdflscape} % To rotate the page when using landscape & longtable
\usepackage{multirow} %access multirow
\usepackage{booktabs} %access \toprule & \bottomrule \cmidrule
\usepackage{changepage}%adjustwidth
\usepackage{ragged2e} % access \justify 
\usepackage{tabularx,ltxtable}
\usepackage{array}

%ltxtable configuration
\newcolumntype{L}{>{\RaggedRight\arraybackslash}X} % flush-left, while allowing hyphenation
\newcolumntype{C}{>{\Centering\arraybackslash}X} % centered, while allowing hyphenation
\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash}p{#1}}

%To change the citation in the table environment 
\usepackage{letltxmacro}

\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}

\begingroup % restrict scope of reset of \textwidth parameter
\setlength\textwidth\textheight
\setlength\tabcolsep{1.25pt}
\begin{table}
\footnotesize
\renewcommand{\arraystretch}{1}%to keep the consistency and got similar render as longtable
\centering
\begin{tabular}{P{3.5cm}P{6cm}P{10cm}}
\toprule
\textbf{C1} & \textbf{C2} & \textbf{C3}\\
\midrule
DL.1. & C1.1. & reg \cite{cit1,cit2,cit3,cit4}, local \cite{cit1,cit2,cit3,cit4}, urban \cite{cit1,cit2,cit3,cit4}, rural \cite{cit1,cit2,cit3,cit4}\\
\phantom{C1} & C1.2. &pla \cite{cit1,cit2,cit3,cit4}, evaluation \cite{cit1,cit2,cit3,cit4}, frameworks \cite{cit1,cit2,cit3,cit4}\\
\phantom{C1} & C1.3. Envi&env and eco \cite{cit1,cit2,cit3,cit4}, lca \cite{cit1,cit2,cit3,cit4}\\
\phantom{C1} & C1.4. evaluation and assessment&investments \cite{cit1,cit2,cit3,cit4}, assessment ms \cite{cit1,cit2,cit3,cit4}, options \cite{cit1,cit2,cit3,cit4}, alternatives \cite{cit1,cit2,cit3,cit4}, plants \cite{cit1,cit2,cit3,cit4}, scenarios \cite{cit1,cit2,cit3,cit4}, production pathways\cite{cit1,cit2,cit3,cit4}\\
\phantom{C1} & C1.5. Site &projects \cite{cit1,cit2,cit3,cit4}, plants \cite{cit1,cit2,cit3,cit4}, stations \cite{cit1,cit2,cit3,cit4}, farms \cite{cit1,cit2,cit3,cit4}\\
\bottomrule
\end{tabular}
\caption{Caption.}
\label{tab:examples}
\end{table}
\endgroup

\bibliography{bibliography}

\end{document}

verwandte Informationen