# Data is getting right aligned

Hello I am using following code to generate table. My requirement is to generate table which fits to text width.

\begin{table}[b]\renewcommand{\arraystretch}{2.0}\setlength\LTleft{0pt}\setlength\LTright{0pt}
\begin{longtable}{@{\extracolsep{\fill}} |l|l|l|l| }
\hline
&Written by&Checked by&Approved by\\\hline

\hline
&Written by&Checked by&Approved by\\\hline

Department&Sales&&\\\hline
Name&ABCD&&\\\hline
Signature&&&\\\hline
Date&21-01-2009&17-06-2019&17-06-2019\\\hline

\end{longtable}\renewcommand{\arraystretch}{1.0}\end{table}


but content is getting right aligned, even if I have mentioned it as center.

• First of why do you have a longtable inside a table float? That does not make sense. Either remove the table env, or convert the longtable into tabular. Remember that longtables can break across pages, while th3e table env cannot. Jun 17 '19 at 11:30
• Next, what is the purpose of @{\extracolsep{\fill}}? Lastly, it is custom here to add a full (but minimal) example along with ones question. This is just a sniplet, and thus those wanting to help have to fill in the rest in order to test your code (in contrast to a minimal example, where one can just copy the code and test as is). Questions with sniplets rather than MWEs tends to get less attention. Jun 17 '19 at 11:33
• @daleif I have longtable inside a table float, to position it bottom of the page. Jun 19 '19 at 4:10
• Again longtables should not be used inside a floating table, it defies the purpose of longtable Jun 19 '19 at 7:49

You can use the xltabular environment, which brings the functionalities of longtable to tabularx.

Also, I replaced changing the value of \arraystretch, which increases the rows height asymmetrically, with the \makegapedcells command, from makecell, so the cells contents be vertically centred.

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{xltabular}
\usepackage{makecell}
\setcellgapes{6pt}

\begin{document}

{\makegapedcells
\begin{xltabular}{\linewidth}{ |*{4}{X|}}
\hline
&Written by&Checked by&Approved by \\
\hline
\hline
&Written by&Checked by&Approved by \\
\hline