0

I am very new to LaTeX, my apologies.

I have created a table using code that I have pieced together from different tex.stackexchange questions. Here is my table:

\documentclass{article}

% packages needed
\usepackage{graphicx}
\usepackage{amsmath}
%\usepackage{cite}
\usepackage{siunitx}
\usepackage[hidelinks]{hyperref}
\usepackage{enumerate}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{setspace}
\usepackage[round]{natbib}
\usepackage[
singlelinecheck=false % <-- important
]{caption}
\usepackage{enumitem}

\newlist{tabitem}{itemize}{1}
\setlist[tabitem]{wide=0pt, nosep, leftmargin= * ,label=\textbullet,after=\vspace{-\baselineskip},before=\vspace{-0.6\baselineskip}}

\usepackage[nottoc]{tocbibind}

\begin{document}


\setlength{\arrayrulewidth}{0.7mm}
\setlength{\tabcolsep}{20pt}
\renewcommand{\arraystretch}{2}
{
\begin{table}[h]
\resizebox{\textwidth}{!}{%
\begin{tabular}{ |p{1.5cm}|p{3cm}|p{1.5cm}|p{3cm}|p{4cm}|p{3cm}|  }
\hline
Variable& Description &Units &Parameters/References & Notes & Programs Used \\
\hline
Topographic position index (TPI)
& 

Comparison of elevation in a cell compared to mean elevation of a specified neighborhood around that cell

& 

unitless
&

\begin{tabitem}
  \item Method = \citep{Weiss2001}
  \item Radius = 10, 25, 50, 100, 150, 300, 500, 1000, 2000
\end{tabitem}
& 

\begin{tabitem}
  \item different resolutions used due to computational rigor
  \item 5 m resolution (TPI10 to TPI300)
  \item 15 m resolution (TPI500)
  \item 30 m resolution (TPI100 to TPI2000)
\end{tabitem}
& 

\begin{tabitem}
  \item ArcGIS - Geomorphometry and Gradient Metrics Toolbox \citep{Evans2014}
\end{tabitem}\\
\hline

Slope
& 

Proxies for water flow, snow movements, erosion, and solar radiation \cite{Leempoel2015}

& 

degrees
&

\begin{tabitem}
  \item Method = \citep{Horn1981}
  \item \cite{Lecours2017}
\end{tabitem}
& 

\begin{tabitem}
  \item Better metric in complex terrain than \citep{Zevenbergen1987} \cite{Lecours2017}
\end{tabitem}
& 

\begin{tabitem}
  \item ArcGIS - TASSE Toolbox \citep{Lecours2017}
\end{tabitem}\\
\cline{1-1}
\cline{3-6}

Aspect
& 


& 

radians
&

\begin{tabitem}
  \item Method = \cite{Horn1981}
  \item \cite{Lecours2017}
\end{tabitem}
& 

\begin{tabitem}
  \item Northernness (cosine aspect)
  \item Easternness (sine of aspect)
\end{tabitem}
& 

\begin{tabitem}
  \item ArcGIS - TASSE Toolbox \citep{Lecours2017}
\end{tabitem}\\
\hline

Topographic wetness index (TWI)
& 

Quantifies topographic control on hydrological processes

& 

radians
&

\begin{tabitem}
  \item Method = \citep{Beven1979}
\end{tabitem}
& 

\begin{tabitem}
  \item Northernness (cosine aspect)
  \item Easternness (sine of aspect)
\end{tabitem}
& 

\begin{tabitem}
  \item QGIS - SAGA Tools
\end{tabitem}\\
\hline

Solar radiation
& 

\begin{tabitem}
    \item Poor durability
    \item Poor gripping strength for soft materials
\end{tabitem}
& 

radians
&

\begin{tabitem}
  \item Method = \citep{Beven1979}
\end{tabitem}
& 

\begin{tabitem}
  \item Northernness (cosine aspect)
  \item Easternness (sine of aspect)
\end{tabitem}
& 

\begin{tabitem}
  \item QGIS - SAGA Tools
\end{tabitem}

\tabularnewline
\hline
\end{tabular}}
\caption{ test}
\label{table:test}
\end{table}
}

\end{document}

I want to left justify the contents of the cells, but when I do that I get an error. I realize that left justification would be controlled by the line here:

\begin{tabular}{ |p{1.5cm}|p{3cm}|p{1.5cm}|p{3cm}|p{4cm}|p{3cm}| }

My understanding is the p in this line is making the horizontal alignment full (LaTeX table capabilities)

I tried changing this line to:

\begin{tabular}{ | l | l | l | l | l | l | }

but then I receive an error. I believe it may be due to the line:

\resizebox{\textwidth}{!}{% which then closes at \end{tabular}}. This is a line that I found on tex.stackexchange for adjusting the dimensions of the table to fit nicely in your document.

Any advice would be much appreciated!

3
  • 1
    Welcome to TeX SX: You should not use \resizebox for tables, as it leads to inconsistent font sizes. Further your table will be larger than the line widths. Better use a smeller font size and reducing the values of \ tabcolsep, which by default is 6pt, which makes 72 pt in all for six columns.
    – Bernard
    Oct 18, 2020 at 23:16
  • @Bernard, I removed the line with \resizebox. I also removed \begin{tabular}{ |p{1.5cm}|p{3cm}|p{1.5cm}|p{3cm}|p{4cm}|p{3cm}| } and added \begin{tabular}{ | l | l | l | l | l | l | } in it's place to attempt the left justification. This resulted in an error related to this: \begin{tabitem} \item Method = \citep{Weiss2001} \item Radius = 10, 25, 50, 100, 150, 300, 500, 1000, 2000 \end{tabitem}. Does changing to left justification prevent me from using bullet points?
    – nateroe
    Oct 18, 2020 at 23:26
  • The l,r and c column types are for single-lined cells. You can't have a list environment in such cells. The nest would probably be to use tabularx, for which you define the overall width, and it calculates the width of the X columns an X column of the pcolumn type).
    – Bernard
    Oct 18, 2020 at 23:43

1 Answer 1

1

One possible way is:

enter image description here

(red lines show text borders, in real document remove package showframe as noted in comment in the MWE)

In MWE (Minimal Working Example) is in comparison to your MWE done the following changes:

  • Removed is \resizebox, since with it you lost control on table font size.
  • For table environment is used tabularx with width equal to \textwidth.
  • Defined is new column type, which left align cells' contents.

Edit

  • Command \citep is not defined in the package cite, consequently I replace them with command cite. You may replace \cite package with some other package, for example natbib, which define \citep.
  • Now I added two additional package: makecell, by which macro makegapedcells is added more vertical space in cells, and multirow, which enable create multirow cells a done in corrected MWE.
  • Added is also siunitx package for writing units (for example 5 m, see MWE)
  • Increased is font size from footnotesize to \small
  • It is not clear, what means numbers in Radius = 10, 25, 50, 100, 150, 300, 500, 1000, 2000. Radius is not unitless ...
  • Off-topic:
    • tables' captions are usual above table
    • comments in MWE are intended to describe code and note, what is specific to this particular MWE and what you should do, when you incorporate it in your real document.
\documentclass{article}
\usepackage[margin=25mm]{geometry} % set suitable page layour
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

% packages needed in this MWE
\usepackage{cite}
\usepackage{siunitx}
% \usepackage{enumerate} % should not be loaded when you use enumitem 

\usepackage[skip=0.33\baselineskip, % new
            font=footnotesize,      % new
            labelfont=bf,           % new
            singlelinecheck=false]{caption}
\usepackage{enumitem}
\newlist{tabitem}{itemize}{1}
\setlist[tabitem]{nosep, 
                leftmargin=*, 
                label=\textbullet,
                after=\vspace{-\baselineskip},
                before=\vspace{-0.6\baselineskip}}
\usepackage{ragged2e}
\usepackage{makecell, multirow,     % new
            tabularx}
\newcolumntype{L}[1]{>{\hsize=#1\hsize\linewidth=\hsize% for left aligning of cells contents
                       \RaggedRight}X} 
\usepackage{siunitx}    % new, for writing units
\usepackage[hidelinks]{hyperref}


\begin{document}
    \begin{table}[h]
    \setlength\tabcolsep{4pt}
    \footnotesize
\begin{tabularx}{\linewidth}{|L{0.7}|L{1.3}|l|L{1}|L{1.2}|L{0.8}|  }
    \hline
Variable& Description &Units &Parameters/\newline References & Notes & Programs Used \\
    \hline
Topographic position index (TPI)
&
Comparison of elevation in a cell compared to mean elevation of a specified neighborhood around that cell
&
unitless
&
\begin{tabitem}
  \item Method = \cite{Weiss2001}
  \item Radius = 10, 25, 50, 100, 150, 300, 500, 1000, 2000
\end{tabitem}
&
\begin{tabitem}
  \item different resolutions used due to computational rigor
  \item \SI{5}{m} resolution (TPI10 to TPI300)
  \item \SI{15}{m} resolution (TPI500)
  \item \SI{30}{m} resolution (TPI100 to TPI2000)
\end{tabitem}
&
\begin{tabitem}
  \item ArcGIS - Geomorphometry and Gradient Metrics Toolbox \cite{Evans2014}
\end{tabitem}\\
    \hline
Slope
&   \multirow[t]{7}{=}{   % defined in `multirow` package
Proxies for water flow, snow movements, erosion, and solar radiation \cite{Leempoel2015}}
&
degrees
&
\begin{tabitem}
  \item Method = \cite{Horn1981}
  \item \cite{Lecours2017}
\end{tabitem}
&
\begin{tabitem}
  \item Better metric in complex terrain than \cite{Zevenbergen1987} \cite{Lecours2017}
\end{tabitem}
&
\begin{tabitem}
  \item ArcGIS - TASSE Toolbox \cite{Lecours2017}
\end{tabitem}\\
    \cline{1-1}
    \cline{3-6}
Aspect
&
&
radians
&
\begin{tabitem}
  \item Method = \cite{Horn1981}
  \item \cite{Lecours2017}
\end{tabitem}
&
\begin{tabitem}
  \item Northernness (cosine aspect)
  \item Easternness (sine of aspect)
\end{tabitem}
&
\begin{tabitem}
  \item ArcGIS - TASSE Toolbox \cite{Lecours2017}
\end{tabitem}\\
    \hline
Topographic wetness index (TWI)
&
Quantifies topographic control on hydrological processes
&
radians
&
\begin{tabitem}
  \item Method = \cite{Beven1979}
\end{tabitem}
&
\begin{tabitem}
  \item Northernness (cosine aspect)
  \item Easternness (sine of aspect)
\end{tabitem}
&
\begin{tabitem}
  \item QGIS - SAGA Tools
\end{tabitem}\\
    \hline
Solar radiation
&
\begin{tabitem}
    \item Poor durability
    \item Poor gripping strength for soft materials
\end{tabitem}
&
radians
&
\begin{tabitem}
  \item Method = \cite{Beven1979}
\end{tabitem}
&
\begin{tabitem}
  \item Northernness (cosine aspect)
  \item Easternness (sine of aspect)
\end{tabitem}
&
\begin{tabitem}
  \item QGIS - SAGA Tools
\end{tabitem}\\
    \hline
\end{tabularx}
\caption{Test}
\label{table:test}
    \end{table}
\end{document}
4
  • Thank you! I am creating this table to put into my thesis. This solution created the desired left alignment in the table, but it also put boxes throughout the entirety of my document. Each page has a box around the text, a long narrow box to the right of the text, and a long thin box at the top of each page. Any thoughts on this?
    – nateroe
    Oct 19, 2020 at 0:28
  • Some of the packages that you removed, did you remove those because they conflict with the solution that you provided, or because they are not required for the solution? Those packages are being used elsewhere in my document, for instance graphicx is being used.
    – nateroe
    Oct 19, 2020 at 0:35
  • Regarding the boxes: take a look at the comment in line 3 of the MWE. The boxes are a guide to the eye that show the size of the textwidth. If you do not want that, don't load the showframe package.
    – leandriis
    Oct 19, 2020 at 5:12
  • 1
    @nateroe, I remove all packages which are not relevant to your problem, add package to show page layout (which had to be removed in your real document as it is noted at package, See edited answer.
    – Zarko
    Oct 19, 2020 at 5:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .