
Я делаю цитаты для диссертационного отчета с помощью пакета natbib:
\usepackage[authoryear,sort,round]{natbib}
\bibliographystyle{apa}
Ссылки должны быть отсортированы по году автора, в тексте должны быть заключены в скобки, что для меня идеально.
Проблема в том, что у меня очень большие столбцы с табличной средой, которые содержат большое количество цитат. Сохранение стиля auhtoryear внутри таблиц затрудняет согласование ширины таблицы с textwidth, даже если я использую настроенные столбцы.
%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}}
Мне нужно переопределить команду cite, чтобы она нумеровалась скобками вместо стиля автора только внутри окружения таблицы. Кроме того, я хочу, чтобы скобки были надстрочными, и я уже нашел решение, но оно всегда со стилем authoryear:
\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}
Вот как выглядит мой документ (минимально необходимый код):
\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}