长表中的引用溢出到边距

长表中的引用溢出到边距

我必须制作两个不同版本的文档:一个带有作者年份引文,另一个带有编号引文。因此,我使用natbib并修改每个文档的natbib选项。

虽然我可以为表格的引文列提供宽度,但我希望它能自动确定宽度,因为编号引文的宽度比作者年份引文所需的宽度小得多。我该如何解决这个问题(最好是自动解决)?

表格边缘

以下是生成该内容的 MWE:

\begin{filecontents*}{database.bib}
@article{Somecite,
    author = {First Last and Fname Lname and F.N. Somename},
    title = {Title of this wonderful article},
    journal = {Unknown journal},
    volume = {2},
    number = {5},
    pages = {100--101},
    year = {1901}
}
@misc{Anothercite,
    author = {{Company Has A Terrible Long Abbreviation (CHATLA)}},
    title = {CHATLNAA does everything for you},
    howpublished = {\url{http://www.chatlnaa.com}},
    year = {2017},
    note = {Accessed today}
}
\end{filecontents*}

\documentclass[a4paper]{report}
\usepackage[authoryear,round,semicolon,sort]{natbib}
%\usepackage[numbers,square,comma,sort]{natbib}
\usepackage{longtable}
\usepackage{rotating}

\newcommand{\bs}{\begin{sideways}}
\newcommand{\es}{\end{sideways}}

\begin{document}

Here is some text, and we refer to \citep{Somecite}. \Citet{Anothercite} is there too. See table.

\scriptsize
\begin{longtable}{|p{2.2cm}cp{2cm}c|p{0.15cm}p{0.15cm}p{0.15cm}p{0.15cm}p{0.15cm}p{0.15cm}p{0.15cm}|}
    \caption{Overview of a table with a lot of numbers.}\label{tbl:numbers} \\
    \hline
    Name &  &Location   &Number 1   & \multicolumn{7}{c|}{Items} \\
                        &   &                   &               &\bs Item 1 \es &\bs Item 2 \es &\bs Item 3 \es &\bs Item 4 \es &\bs Item 5 \es &\bs Item 6 \es &\bs Item 7 \es \\
    \hline \endhead
    \hline \endfoot
    \hline \endlastfoot
A name that is short    &\citep{Somecite}   &Locaville  &100    &   &x  &   &   &   &   &\\
Some name that is relatively long, but alright  &\citep{Anothercite}    &Abroad & 900 m &   &x  &   &   &x &    &\\
\end{longtable}


\bibliographystyle{plainnat}
\bibliography{database} 

\end{document}

答案1

您的引用位于一c栏中,并且与一栏不同,它不会分布在多行上p

要获得居中p类型的列,请加载包并在声明前array添加。或者,另外加载包并使用其命令代替,这样可以更好地换行并具有更多潜在的连字符点。在下面,我已完成此操作并制作了您的第一列。我还调整了列宽,以便表格更适合页面。>{\centering\arraybackslash}pragged2e\Centering\centering\RaggedRight

示例输出

\begin{filecontents*}{database.bib}
@article{Somecite,
    author = {First Last and Fname Lname and F.N. Somename},
    title = {Title of this wonderful article},
    journal = {Unknown journal},
    volume = {2},
    number = {5},
    pages = {100--101},
    year = {1901}
}
@misc{Anothercite,
    author = {{Company Has A Terrible Long Abbreviation (CHATLA)}},
    title = {CHATLNAA does everything for you},
    howpublished = {\url{http://www.chatlnaa.com}},
    year = {2017},
    note = {Accessed today}
}
\end{filecontents*}

\documentclass[a4paper]{report}
\usepackage[authoryear,round,semicolon,sort]{natbib}
%\usepackage[numbers,square,comma,sort]{natbib}
\usepackage{longtable,array}
\usepackage{rotating}
\usepackage{ragged2e}

\newcommand{\bs}{\begin{sideways}}
\newcommand{\es}{\end{sideways}}

\begin{document}

Here is some text, and we refer to \citep{Somecite}. \Citet{Anothercite} is there too. See table.

\scriptsize
\begin{longtable}{|>{\RaggedRight\arraybackslash}p{2cm}>{\Centering\arraybackslash}p{1.5cm}p{1.5cm}c|p{0.16cm}p{0.16cm}p{0.16cm}p{0.16cm}p{0.16cm}p{0.16cm}p{0.16cm}|}
    \caption{Overview of a table with a lot of numbers.}\label{tbl:numbers} \\
    \hline
    Name &  &Location   &Number 1   & \multicolumn{7}{c|}{Items} \\
                        &   &                   &               &\bs Item 1 \es &\bs Item 2 \es &\bs Item 3 \es &\bs Item 4 \es &\bs Item 5 \es &\bs Item 6 \es &\bs Item 7 \es \\
    \hline \endhead
    \hline \endfoot
    \hline \endlastfoot
A name that is short    &\citep{Somecite}   &Locaville  &100    &   &x  &   &   &   &   &\\
Some name that is relatively long, but alright  &\citep{Anothercite}    &Abroad & 900 m &   &x  &   &   &x &    &\\
\end{longtable}


\bibliographystyle{plainnat}
\bibliography{database} 

\end{document}

相关内容