Graphics, Figures & TablestabularX- leftalign in large table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
gwenywar
Posts: 5
Joined: Thu Sep 11, 2014 4:48 pm

tabularX- leftalign in large table

Post by gwenywar »

Hey everyone,

I know this has been previously asked and I've been through lots of posts which talked about aligning text in the tabularX environment, but I just simple either don't understand it or don't get it work. All the examples are usually made for simple and short tables, but that's not what I have...

I can't get a minimal example to work either, it's a 300 page document and accordingly my preamble rather complex, so when I try to get the table with the minimum I think I need, it won't work. So here is the code that I use to get the table:

Code: Select all

\begin{tabularx}{\textwidth}{XXX}
\textbf{Name} & \textbf{Company} & \textbf{Cat. No.}  \\ \toprule
\endhead
\endfoot
Sodium chloride (NaCl) &	Fisher Scientific, Loughborough, UK & 10274392\\
Potassium chloride (KCl) &	Fisher Scientific &	10355810\\
Sodium dihydrogen phosphate (NaH\textsubscript{2}PO\textsubscript{4}) &	Fisher Scientific&	11462904\\
Sodium bicarbonate (NaHCO\textsubscript{3})&	Sigma-Aldrich, Dorset, UK&	31437\\
D-Glucose anhydrous&	Sigma-Aldrich&	10254480\\
Magnesium chloride (MgCl)&	Sigma-Aldrich&	M9272\\
Calcium chloride (CaCl)&	Sigma-Aldrich&	21114\\
Magnesium sulfate (MgSO\textsubscript{4})&	Sigma-Aldrich&	208094\\
2,3-dihydroxy-6-nitro-7-sulfamoyl-benzo[f]quinoxaline-2,3-dione 
(NBQX disodium salt) &	Tocris, Bristol, UK&	0373	\\
Bicuculline methiodide &	Tocris &	2503\\
Ca\textsuperscript{2+}/Mg\textsuperscript{2+}-free Hank’s balances salt solution (HBSS) &	Invitrogen, Paisley, UK&	14175095\\
Fetal Bovine Serum (FBS) &	Sigma-Aldrich&	F7524\\
Penicillin-Streptomycin solution&	Sigma-Aldrich&	P0781\\
Sodium hydroxide (NaOH) &	Fisher Scientific&	10000650\\
Papain&	Worthington Biochemicals, Lakewood, USA&	LK003178\\
DNase I&	Roche, West Sussex, UK&	11284932001\\
Dulbecco's Modified Eagle’s Medium (DMEM)  &	Invitrogen&	D6429\\
Poly-L-lysine&	Sigma-Aldrich&	P1524\\
HEPES&	Sigma-Aldrich&	H4034\\
Oregon Green 488 BAPTA-1, AM&	Invitrogen&	O6807\\
Adenosine triphosphate disodium salt (ATP) &	Sigma-Aldrich&	A26209\\
Glutamic acid &	Sigma-Aldrich &	G1001\\
Carbachol&	Sigma-Aldrich&	Y0000113\\
Phorbol 12-myristate 13-acetate (PMA) &	Tocris&	1201\\
WIN55,212-2 mesylate (WIN55) &	Sigma-Aldrich&	W105\\
\hline
\end{tabularx}


It spans over two pages and some columns have lots of text. This works as it is but it looks rubbish (see attached image) because it centers the text..

all I need is to have it left-aligned...I tried {l l l} but that doesn't work..nor anything else I tried.

Can someone please help me..this is the final thing I need so that I can submit my PhD, so I'm rather desperate at the moment and welcome any suggestions!
Attachments
Table example
Table example
Capture.PNG (49.47 KiB) Viewed 15960 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

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: tabularX- leftalign in large table

Post by Johannes_B »

The example is not ccompilable, the preamble is missing.

Your last column is rather narrow, use an l-column for that.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
gwenywar
Posts: 5
Joined: Thu Sep 11, 2014 4:48 pm

tabularX- leftalign in large table

Post by gwenywar »

Hey..I know this isn't working, see my comment above..I didn't want to post my whole preamble as there is lots of stuff which seems to influence the outcome of this, but here it is now. I deleted some stuff to make it a bit shorter. If you copy and paste this, it works I believe..Thanks for your help!

Code: Select all

\documentclass[12pt,a4paper,oneside,headinclude=true]{scrreprt}
     
\usepackage[UKenglish]{babel}
\usepackage{siunitx}
\usepackage [T1]{fontenc}
\usepackage{lmodern}
\usepackage {listings} % to include for example MATLAB scripts
\usepackage {setspace} % allows 1.5 spacing, needs command \onehalfspacing in each file
\usepackage{sidecap}
\usepackage[font=small,labelfont=bf,format=plain]{caption}
\usepackage{float}
\usepackage[pdftex]{graphicx}
\usepackage{ragged2e}
\usepackage[nottoc,numbib]{tocbibind}
\usepackage{nomencl}
\usepackage{glossaries}
\usepackage{helvet}
\usepackage{geometry}
\renewcommand{\familydefault}{\sfdefault}   %change font to Arial
\renewcommand{\baselinestretch}{1.5} 
\usepackage{fixltx2e}  %to solve issues with sub and superscript
\usepackage{siunitx}  %SI units
\usepackage{tocloft}
\usepackage{longtable}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{scrpage2}
\pagestyle{scrheadings}
\ofoot[\pagemark]{\pagemark} 
\usepackage[pdftex]{graphicx}
\renewcommand{\headfont}{}
\usepackage{sidecap}
\usepackage{ltablex,booktabs}
\usepackage{listings}
\usepackage{array}
\usepackage{tabularx}
%Set margins:
\geometry{
 a4paper,
 total={210mm,297mm},
 left=50mm,
 right=25mm,
 top=25mm,
 bottom=25mm,
 }
\begin{document}

\begin{tabularx}{\textwidth}{XXl}
\textbf{Name} & \textbf{Company} & \textbf{Cat. No.}  \\ \toprule
\endhead
\endfoot
Sodium chloride (NaCl) &	Fisher Scientific, Loughborough, UK & 10274392\\
Potassium chloride (KCl) &	Fisher Scientific &	10355810\\
Sodium dihydrogen phosphate (NaH\textsubscript{2}PO\textsubscript{4}) &	Fisher Scientific&	11462904\\
Sodium bicarbonate (NaHCO\textsubscript{3})&	Sigma-Aldrich, Dorset, UK&	31437\\
D-Glucose anhydrous&	Sigma-Aldrich&	10254480\\
Magnesium chloride (MgCl)&	Sigma-Aldrich&	M9272\\
Calcium chloride (CaCl)&	Sigma-Aldrich&	21114\\
Magnesium sulfate (MgSO\textsubscript{4})&	Sigma-Aldrich&	208094\\
2,3-dihydroxy-6-nitro-7-sulfamoyl-benzo[f]quinoxaline-2,3-dione 
(NBQX disodium salt) &	Tocris, Bristol, UK&	0373	\\
Bicuculline methiodide &	Tocris &	2503\\
Ca\textsuperscript{2+}/Mg\textsuperscript{2+}-free Hank’s balances salt solution (HBSS) &	Invitrogen, Paisley, UK&	14175095\\
Fetal Bovine Serum (FBS) &	Sigma-Aldrich&	F7524\\
Penicillin-Streptomycin solution&	Sigma-Aldrich&	P0781\\
Sodium hydroxide (NaOH) &	Fisher Scientific&	10000650\\
Papain&	Worthington Biochemicals, Lakewood, USA&	LK003178\\
DNase I&	Roche, West Sussex, UK&	11284932001\\
Dulbecco's Modified Eagle’s Medium (DMEM)  &	Invitrogen&	D6429\\
Poly-L-lysine&	Sigma-Aldrich&	P1524\\
HEPES&	Sigma-Aldrich&	H4034\\
Oregon Green 488 BAPTA-1, AM&	Invitrogen&	O6807\\
Adenosine triphosphate disodium salt (ATP) &	Sigma-Aldrich&	A26209\\
Glutamic acid &	Sigma-Aldrich &	G1001\\
Carbachol&	Sigma-Aldrich&	Y0000113\\
Phorbol 12-myristate 13-acetate (PMA) &	Tocris&	1201\\
WIN55,212-2 mesylate (WIN55) &	Sigma-Aldrich&	W105\\
\hline
\end{tabularx}


\subsection*{Equipment:} 
\begin{tabularx}{\textwidth}{XXl}
\textbf{Name} & \textbf{Company} & \textbf{Name}  \\ \toprule
\endhead
\endfoot
Vibratome & Leica, Cambridge, UK & VT 1000S\\
Nikon Upright Microscope & Nikon, Tokyo, Japan & Eclipse E600FN \\
Borosilicate glass capillaries &	Harvard Apparatus Ltd, Kent, UK&	Cat. No.: 30--0066\\
Pipette puller &	Tritech Research, Los Angeles, USA&	PP--830\\
Micro Forge &	Digitimer Ltd, Welwyn, UK&	MF--830\\
Axopatch\textsuperscript{TM} Amplifier &	Molecular devices, Sunnyvale, USA &	Model 200B\\
Microconverter A/D &	CED, Cambridge, UK&	1401 mkII\\
Stimulator &	Digitimer Ltd, Welwyn, UK&	DS3\\
Nikon inverted microscope & Nikon,Tokyo,JapanEclipse Ti\\
Zyla sCMOS camera & Andor, Belfast, UK&	Version 4.2\\
LED illumination system & Cool LED, Andover, UK &	pE--100 470nm/550nm\\
\hline
\end{tabularx}

\subsection*{Software:} 
\begin{tabularx}{\textwidth}{XXl}
\textbf{Name} & \textbf{Company} & \textbf{Cat. No.}  \\ \toprule
\endhead
\endfoot
Spike 2&CED, Cambridge, UK&5.09 (Windows XP)\\
Graphpad Prism&	Graphpad Software, La Jolla, US&	Version 6\\
Microsoft Excel&	Microsoft, Redmond, USA&	Microsoft Office 2010\\
Matlab&	Mathworks, Cambridge, UK&	Version 8.1\\
ImageJ (including Micro-Manager)&	National Institute of Health, Bethesda, USA&	Version 1.48q\\
\hline
\end{tabularx}

\end{document}
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

tabularX- leftalign in large table

Post by Johannes_B »

The simplest solution seems to be to left-align the columns.
But your type block is quite narrow and your font size is huge.

Code: Select all

\newcolumntype{L}{>{\raggedright\arraybackslash}X}
Now use the the new column type L instead of X in your tables.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
gwenywar
Posts: 5
Joined: Thu Sep 11, 2014 4:48 pm

Re: tabularX- leftalign in large table

Post by gwenywar »

Thanks, this works well. You saved me from insanity.. :roll:
Post Reply