
我正在使用 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}