我是 Latex 的新手,我正在使用一个名为 overleaf 的模板Concordia University Thesis Template
来写我的论文。此外,我有一个包含大量文本的宽表,由于我有特定的页边距,所以我无法更改它们。问题是表格超出了页面,我尝试将文本放在同一个单元格中,但仍然没有解决问题,表格看起来像这样
我使用的代码是这样的
%################### BEGIN: Environment Setup #######################
\documentclass[letterpaper,11pt,onecolumn,final]{report} % define document type
\usepackage[left=1.5in,right=1in,top=1in,bottom=1in]{geometry} % margin settings, required by Concordia University
\usepackage{setup/ConcordiaU} % page maker definition for Title Page, Signature Page, and styles customized for Concordia University
\usepackage{setspace} % manually configuration to spacing is needed.
\doublespacing % double spaced, required by Concordia University
\usepackage[natbibapa]{apacite} % citation and bibliography package
\usepackage{amsmath} % equations/formulas
\usepackage[dvips]{graphicx} % to include images. For those who use .eps images. The option [dvips] must be there.
\graphicspath{{figures/}} % all figures are put in the folder named "figures"
%\usepackage{subfigure} % enable subfigures
\usepackage{multirow} % multirow in a table cellcc
\usepackage{indentfirst} % add indent to the first line of each paragraph
\usepackage{algorithmicx, algpseudocode} % write algorithms in pseudo code in a uniform style
\usepackage{algorithm} % algorithm and pseudocode environment
\usepackage[colorlinks,linkcolor=blue,anchorcolor=blue,citecolor=blue,urlcolor=blue]{hyperref} % blue color for all links, urls and citations
\usepackage{enumitem}
\renewcommand{\labelenumi}{(\arabic{enumi})} % "(1)." style for enumerated items
\renewcommand{\labelitemii}{$\circ$} % (o) for the second level bullet items
\usepackage[titletoc,title]{appendix}
\ref{table:GIS_API} illustrates all possible API that can be used to extract data from it.
\begin{table}[htb]
\begin{tabular}{|c|c|c|c|c|c|}
\label{table:GIS_API}
\hline Application name & Owned by & Has an API? & API NAME & Pricing & Number of transaction \\ \hline
openstreetmap & Openstreetmap Orgnization & yes & Overpass api & Free & Unlimited \\ \hline
Google Earth engine &
Google inc. &
yes &
Eearth engine api &
\begin{tabular}[c]{@{}c@{}}free for research, \\ education, and\\ nonprofit use.\\ For commercial\\ applications, \\ they offer paid \\ commercial licenses.\end{tabular} &
-- \\ \hline
Tomtom developer & tomtom & yes & Tomtom maps-api & 0.42\$ per 1000 tranaction & Limited by the cost \\ \hline
HERE developer &
Here &
yes &
Rest api &
Has a free version and paied version &
\begin{tabular}[c]{@{}c@{}}The free version has \\ 250K transaction \\ and you can pay for more\end{tabular} \\ \hline
\end{tabular}
\end{table}
有没有办法让表格在页面边框内对齐
答案1
也许使用 tabularx 和/或定义您自己的列类型可以解决您的问题:
\documentclass[letterpaper,11pt,onecolumn,final]{report} % define document type
\usepackage[left=1.5in,right=1in,top=1in,bottom=1in]{geometry} % margin settings, required by Concordia University
\usepackage{setup/ConcordiaU} % page maker definition for Title Page, Signature Page, and styles customized for Concordia University
\usepackage{setspace} % manually configuration to spacing is needed.
\doublespacing % double spaced, required by Concordia University
\usepackage{booktabs}
\usepackage{cleveref}
\usepackage{array}
\newcolumntype{x}[1]{>{\centering\arraybackslash\hspace{0pt}}p{#1}}
\usepackage{tabularx}
\begin{document}
\Cref{table:GIS_API} illustrates all possible API that can be used to extract data from it.
\begin{table}[htb]
\caption{text\label{table:GIS_API}}
\begin{tabularx}{\linewidth}{x{.8in} x{1in} X x{.8in} x{1in} x{1.2in} }
\toprule
Application name & Owned by & Has an API? & API NAME & Pricing & Number of transaction \\ \midrule
openstreetmap & Openstreetmap Organization & yes & Overpass api & Free & Unlimited \\ \midrule
Google Earth engine & Google inc. & yes & Earth engine api & free for research, education, and nonprofit use. For commercial applications, they offer paid commercial licenses. &
-- \\ \midrule
Tomtom developer & tomtom & yes & Tomtom maps-api & 0.42\$ per 1000 transaction & Limited by the cost\\ \midrule
HERE developer & Here & yes & Rest api & Has a free version and paid version & The free version has 250K transaction and you can pay for more \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
为了更好地概览,我删除了与问题无关的包。但基本上我添加\usepackage{tabularx}
并定义了你的表是\linewidth
-wide。为了确保你的行断开,我必须x
使用array
-package 定义一个新的列类型。(此列类型的定义是从这个答案。
另外,我擅自删除了多余的线条,并\hline
使用booktabs
' \toprule
、\midrule
和替换了过时的线条(?) \bottomrule
。在表格中使用垂直线基本上是一种不好的做法,但是如果您喜欢它们,当然可以重新添加它们。
编辑:对于任何想要尝试解答这个问题的人来说,我找到并使用的相关模板是这样的:U Concordia LaTeX 论文模板