0

I'm new to Latex, and I'm using an overleaf template called Concordia University Thesis Template to write my thesis. Furthermore, I have a wide table containing a lot of text, and since I'm obligated with specific page margins, I can't change them. the problem that the table is getting out of the page, and I tried to make the text under each other in the same cell but still didn't fix the solution for me, and the table looks like thistable view

the code that I used is like this

%###################  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}

is there a way to make the table aligned within the page borders

Paul Gessler
  • 29,607
ربيع
  • 105
  • Welcome to TeX.SE. If you wish to receive effective help, it would really help if you provided more pertinent information about the document. In particular, which document class is in use, which font and font size do you employ, and how wide is the text block? – Mico Mar 17 '21 at 16:31
  • @Werner yes I read this answer before the only solution that adjusts the table was using adjustbox but it make the table not organized – ربيع Mar 17 '21 at 16:36
  • @Mico thanks, should i add this informations into the question above ? – ربيع Mar 17 '21 at 16:36
  • 1
    Do not use adjustbox to make a table fit into the available space since it leads to inconsistent font sizes. Please also make your code compilable by adding the documentclass as well as the relevant packages. Also move the \label outside of the tabular environment. You should get a corresponding error message upon rying to compile your code. – leandriis Mar 17 '21 at 16:40
  • In order to make your table fit into the textwidth, start by removing all manual linebreaks and nested tabulars and let p type columns of appropriate widths handle the required linebreaks for you. – leandriis Mar 17 '21 at 16:40
  • 1
    The ConcordiaU package isn't available in any of the standard TeX distributions. Is it available online somewhere? – Mico Mar 17 '21 at 16:49
  • @mico this package is in a separate file In the thesis template on overleaf Concordia University Thesis Template that's why they add the path in it – ربيع Mar 17 '21 at 16:53
  • Not everyone on this site has an Overleaf account. – Mico Mar 17 '21 at 17:00
  • Off-topic: Instead of writing linkcolor=blue, anchorcolor=blue, citecolor=blue, urlcolor=blue, do consider writing allcolors=blue. – Mico Mar 17 '21 at 17:02

1 Answers1

0

Maybe using tabularx and/or defining your own column-types solves your issue:

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

For a better overview I removed the packages that were not relevant to the question. But basically I added \usepackage{tabularx} and defined your table to be \linewidth-wide. To make sure your lines break, I had to define a new column-type x using array-package. (The definition of this column-type was copied from this answer.)

Also, I took the liberty of removing the superfluous lines and replaced the out-dated(?) \hline using booktabs' \toprule, \midrule, and \bottomrule. Using vertical lines in tables is basically bad practice, but if you like them, you can re-add them, of course.

EDIT: For anyone, who wants to take their chances with this question, the template in question that I found and used is this: U Concordia LaTeX thesis template

Markus G.
  • 2,735