Graphics, Figures & TablesNewbie needs help in basic table formatting

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
dlongddsma
Posts: 3
Joined: Tue Jun 24, 2025 5:39 am

Newbie needs help in basic table formatting

Post by dlongddsma »

To anybody that answers me plea for help:

As the subject line says, I just started using LaTeX the past few weeks. I am trying to create tables, but cannot. I have looked everywhere I can think on the internet to try to find answers, and some of them are close, but none are perfect.
So it looks almost perfect, the problem is I would like the table name and number to be further left justified. I put the {l} code in there, but it's not as far justified as I would like (this is a minor problem). Second, and more important, I cannot get the very bottom row to put my source information in there correctly. I can either have the information in first, left, cell, but the info is crammed into the left, small cell. OR, I use the \multicolumn command to combine the two cells, but then the cell content doesn't scroll.

This code gives me the two cells at the end with the reference info crammed into the first cell (Shown in first pic)(I'm using the "longtable" package because other tables are very long).

Code: Select all

\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage{booktabs}
\usepackage{longtable}
\begin{document}
\centering
\scriptsize
\label{tab:label}
\begin{longtable}{p{4cm}p{8.5cm}}
\caption{l}{EXAMPLES OF BIOLOGICAL WARFARE THROUGH HISTORY}\\
\hline
Time/Year & Event\\
\hline
Pre-historic times & Melanesian (Vanuatu) tribesman used arrowheads contaminated with tetanus\\
14th  century BC & Hittite army sends rams infected with tularemia to their enemies\\
\hline

Adapted from Oliveira, Manuela, Gabriella Mason-Buck, David Ballard, Wojciech Branicki, and António Amorim. 2020. “Biowarfare, Bioterrorism and Biocrime: A Historical Overview on Microbial Harmful Applications.”
\textit{Forensic Science International} 
314 (September): 1–12. https://doi.org/10.1016/j.forsciint.2020.110366 and Long, Daniel E. 
\textit{WAR IS HELL: The Rise of Total War from Napoleon to the Present} 
(Mechanicsburg, PA: Stackpole Books, 2025).

\end{longtable}
\end{document}
And this code combines the cells, but with no scrolling and the title mysteriously dissapeared.(Second pic)

Code: Select all

\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage{booktabs}
\usepackage{longtable}
\begin{document}
\centering
\scriptsize
\label{tab:label}
\begin{longtable}{p{4cm}p{8.5cm}}
\caption{l}{EXAMPLES OF BIOLOGICAL WARFARE THROUGH HISTORY}\\
\hline
Time/Year & Event\\
\hline
Pre-historic times & Melanesian (Vanuatu) tribesman used arrowheads contaminated with tetanus\\
14th  century BC & Hittite army sends rams infected with tularemia to their enemies\\
\hline
\multicolumn{2}{l}
Adapted from Oliveira, Manuela, Gabriella Mason-Buck, David Ballard, Wojciech Branicki, and António Amorim. 2020. “Biowarfare, Bioterrorism and Biocrime: A Historical Overview on Microbial Harmful Applications.”
\textit{Forensic Science International} 
314 (September): 1–12. https://doi.org/10.1016/j.forsciint.2020.110366 and Long, Daniel E. 
\textit{WAR IS HELL: The Rise of Total War from Napoleon to the Present} 
(Mechanicsburg, PA: Stackpole Books, 2025).

\end{longtable}
\end{document}
Help? What do I need to do? And thank you for your help.
DL
Attachments
Test Pic 1.jpg
Test Pic 1.jpg (112.07 KiB) Viewed 236 times
Test Pic 2.jpg
Test Pic 2.jpg (57.37 KiB) Viewed 236 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Re: Newbie needs help in basic table formatting

Post by Stefan Kottwitz »

Hi,

welcome to the forum!

With \multicolumn, you just forgot to put the third argument in curly braces too:

Code: Select all

\multicolumn{2}{l}{...text...}
Also, you can use a p column here instead of l.

To adjust captions, I would highly recommend using the caption package. Here in your example:

Code: Select all

\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage{booktabs}
\usepackage{caption}
\captionsetup[table]{labelformat=simple,justification=raggedright,singlelinecheck=false,margin=-0.6cm}
\usepackage{longtable}
\begin{document}
\centering
\scriptsize
\label{tab:label}
\begin{longtable}{p{4cm}p{8.5cm}}
\caption{EXAMPLES OF BIOLOGICAL WARFARE THROUGH HISTORY}\\
\hline
Time/Year & Event\\
\hline
Pre-historic times & Melanesian (Vanuatu) tribesman used arrowheads contaminated with tetanus\\
14th  century BC & Hittite army sends rams infected with tularemia to their enemies\\
\hline
\multicolumn{2}{p{12.9cm}}{
Adapted from Oliveira, Manuela, Gabriella Mason-Buck, David Ballard, Wojciech Branicki, and António Amorim. 2020. “Biowarfare, Bioterrorism and Biocrime: A Historical Overview on Microbial Harmful Applications.”
\textit{Forensic Science International} 
314 (September): 1–12. https://doi.org/10.1016/j.forsciint.2020.110366 and Long, Daniel E. 
\textit{WAR IS HELL: The Rise of Total War from Napoleon to the Present} 
(Mechanicsburg, PA: Stackpole Books, 2025).}

\end{longtable}
\end{document}
longtable.png
longtable.png (98.21 KiB) Viewed 189 times
Stefan
LaTeX.org admin
dlongddsma
Posts: 3
Joined: Tue Jun 24, 2025 5:39 am

Re: Newbie needs help in basic table formatting

Post by dlongddsma »

THANK YOU!
Now how do I put the text that follow back to normal? Before, it was full justified, double-spaced, and a bigger font. Now it's fully centered, single-spaced, and note-sized font. Here is the original prematter (is that right? I can't remember.) for you.

Code: Select all

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LaTeX book template                           %%
%% Author:  Amber Jain (http://amberj.devio.us/) %%
%% License: ISC license                          %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[letter,12pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Source: http://en.wikibooks.org/wiki/LaTeX/Hyperlinks %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{ragged2e}
\usepackage{blindtext}
\usepackage{dirtytalk}
\usepackage{csquotes}
\usepackage{longtable}
\usepackage{tabularx}
\usepackage{threeparttablex}
\usepackage{threeparttable}
\usepackage{tablefootnote}
\usepackage{environ}
\usepackage[english]{babel}
\usepackage[notes,backend=biber]{biblatex-chicago}}
\bibliography{sample}
\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage{booktabs}
\usepackage{caption}
\captionsetup[table]{labelformat=simple,justification=raggedright,singlelinecheck=false,margin=-0.6cm}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 'dedication' environment: To add a dedication paragraph at the start of book %
% Source: http://www.tug.org/pipermail/texhax/2010-June/015184.html            %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newenvironment{dedication}
{
   \cleardoublepage
   \thispagestyle{empty}
   \vspace*{\stretch{1}}
   \hfill\begin{minipage}[t]{0.66\textwidth}
   \raggedright
}
{
   \end{minipage}
   \vspace*{\stretch{3}}
   \clearpage
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Chapter quote at the start of chapter        %
% Source: http://tex.stackexchange.com/a/53380 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\renewcommand{\@chapapp}{}% Not necessary...
\newenvironment{chapquote}[2][2em]
  {\setlength{\@tempdima}{#1}%
   \def\chapquote@author{#2}%
   \parshape 1 \@tempdima \dimexpr\textwidth-2\@tempdima\relax%
   \itshape}
  {\par\normalfont\hfill--\ \chapquote@author\hspace*{\@tempdima}\par\bigskip}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% First page of book which contains 'stuff' like: %
%  - Book title, subtitle                         %
%  - Book author name                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Book's title and subtitle
\title{\Huge \textbf{MY WORKING PAPER}  \footnote{This is a footnote.} \\ \huge Which is Driving Me Crazy\footnote{This is yet another footnote.}}
% Author
\author{\textsc{Dlongddsma}\thanks{\url{www.example.com}}}

\setlength\LTleft\parindent 
\setlength\LTright\fill

\begin{document}

\frontmatter
\maketitle

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Add a dedication paragraph to dedicate your book to someone %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{dedication}
Dedicated to my son
\end{dedication}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Auto-generated table of contents, list of figures and list of tables %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\tableofcontents
\listoffigures
\listoftables

\mainmatter

%%%%%%%%%%%
% Preface %
%%%%%%%%%%%
\chapter*{Preface}
This gives me what I want, so I either need to "resume" my original formatting, or "exit" my new formatting.
Sorry for the trouble
DL
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Re: Newbie needs help in basic table formatting

Post by Stefan Kottwitz »

Small comment, please always use the "Code"-Button when posting Code here (editor button with </> symbol when writing), for formatting and also direct online compiling. I edited it in the previous code for you.

The preamble doesn't tell me anything about what happened in or after the table. Please always post a small example with the issue, so it can be tested and fixed. Also in the first examples, \begin{document} and \end{document} were missing, but I quickly added that to make the code snippets compilable.

Show some code that produces the issue (when I click the "Run LaTeX here" button) and I'm sure I can fix it.

Stefan
LaTeX.org admin
dlongddsma
Posts: 3
Joined: Tue Jun 24, 2025 5:39 am

Re: Newbie needs help in basic table formatting

Post by dlongddsma »

Thank you again. OK, so this is the original code:

Code: Select all

\documentclass[a4paper,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{ragged2e}
\usepackage{blindtext}
\usepackage{dirtytalk}
\usepackage{csquotes}
\usepackage{longtable}
\usepackage{tabularx}
\usepackage{threeparttablex}
\usepackage{threeparttable}
\usepackage{tablefootnote}
\usepackage{environ}
\usepackage[english]{babel}
\usepackage[notes,backend=biber]{biblatex-chicago}
\bibliography{sample}

\usepackage{hyperref}
\usepackage{graphicx}
\usepackage[english]{babel}


\begin{document}

\chapter*{Preface}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis risus ante, auctor et pulvinar non, posuere ac lacus. Praesent egestas nisi id metus rhoncus ac lobortis sem hendrerit. Etiam et sapien eget lectus interdum posuere sit amet ac urna.

\centering
\scriptsize
\label{tab:label}
\begin{longtable}{p{4cm}p{8.5cm}}
\caption{l}{EXAMPLES OF BIOLOGICAL WARFARE THROUGH HISTORY}\\
\hline
Time/Year & Event\\
\hline
Pre-historic times & Melanesian (Vanuatu) tribesman used arrowheads contaminated with tetanus\\
14th  century BC & Hittite army sends rams infected with tularemia to their enemies\\
\hline

Adapted from Oliveira, Manuela, Gabriella Mason-Buck, David Ballard, Wojciech Branicki, and António Amorim. 2020. “Biowarfare, Bioterrorism and Biocrime: A Historical Overview on Microbial Harmful Applications.”
\textit{Forensic Science International} 
314 (September): 1–12. https://doi.org/10.1016/j.forsciint.2020.110366 and Long, Daniel E. 
\textit{WAR IS HELL: The Rise of Total War from Napoleon to the Present} 
(Mechanicsburg, PA: Stackpole Books, 2025).
\end{longtable}
\end{document}
And here's how it looks:
Test Pic 1.jpg
Test Pic 1.jpg (109.89 KiB) Viewed 67 times
Now for the new code:

Code: Select all


\documentclass[a4paper,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{ragged2e}
\usepackage{blindtext}
\usepackage{dirtytalk}
\usepackage{csquotes}
\usepackage{longtable}
\usepackage{tabularx}
\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage{booktabs}
\usepackage{caption}
\captionsetup[table]{labelformat=simple,justification=raggedright,singlelinecheck=false,margin=-0.6cm}
\usepackage{longtable}
\begin{document}

\Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis risus ante, auctor et pulvinar non, posuere ac lacus. Praesent egestas nisi id metus rhoncus ac lobortis sem hendrerit. Etiam et sapien eget lectus interdum posuere sit amet ac urna.
\centering
\scriptsize
\label{tab:label}
\begin{longtable}{p{4cm}p{8.5cm}}
\caption{EXAMPLES OF BIOLOGICAL WARFARE THROUGH HISTORY}\\
\hline
Time/Year & Event\\
\hline
Pre-historic times & Melanesian (Vanuatu) tribesman used arrowheads contaminated with tetanus\\
14th  century BC & Hittite army sends rams infected with tularemia to their enemies\\
\hline
\multicolumn{2}{p{12.9cm}}{
Adapted from Oliveira, Manuela, Gabriella Mason-Buck, David Ballard, Wojciech Branicki, and António Amorim. 2020. “Biowarfare, Bioterrorism and Biocrime: A Historical Overview on Microbial Harmful Applications.”
\textit{Forensic Science International} 
314 (September): 1–12. https://doi.org/10.1016/j.forsciint.2020.110366 and Long, Daniel E. 
\textit{WAR IS HELL: The Rise of Total War from Napoleon to the Present} 
(Mechanicsburg, PA: Stackpole Books, 2025).}

\end{longtable}
\end{document}
And how it looks:
Test Pic 2.jpg
Test Pic 2.jpg (149.32 KiB) Viewed 67 times
That's what I meant, now the formatting for the main body text is all screwed up. help? [wimper]
Thanks again (and I hope I did this correctly this time),
Dlongddsma
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Re: Newbie needs help in basic table formatting

Post by Stefan Kottwitz »

You have a \centering command here that causes it.

The difference between the first and the second code is: in the first code, you have an empty line before the \centering command, which means a paragraph break. In the second code, you have no empty line before \centering, so it's whin the same paragraph, that Lorem text with \centering, so that gets centered too. Just make an empty line before \centering.

Stefan
LaTeX.org admin
Post Reply