1

This question already has an answer here:

I want to center vertically elements in my two columns table just in my left column, which I want it to be 30% of the line width and the second one to be left aligned and 70% of the line width. I have succeeded doing these two things separately but not together in the same table.

My code is the following:

\setlength{\arrayrulewidth}{1mm}
\setlength{\tabcolsep}{18pt}
\usepackage{array}
\usepackage{tabularx}

{\rowcolors{1}{blue!50!white!60}{blue!30!white!70}
\begin{tabularx}{\linewidth}{ |>{\arraybackslash}m{0.3\linewidth}|>{\arraybackslash}m{0.7\linewidth}|}
\hline
ID & GUIDEME-FR-FUNC-001 \\
TITLE & Functions Start Over \\
AUTHOR & IBM CIO\\
CREATION DATE & 25-09-2018 \\
SOURCE & GUIDEME-FR-FUNC-001 \\
SUBSYSTEM & Functions \\
TYPE & Functional \\
PRIORITY & High \\
STATUS & Approved \\
DESCRIPTION & The system shall permit users to start over and look for another room \\
TEST PLAN & Check if it is possible to go back to the main page once instructions have been displayed \\
\hline
\end{tabularx}
}

And the outcome is the following:

enter image description here

marked as duplicate by leandriis, Raaja, Stefan Pinnow, Phelype Oleinik, Schweinebacke Apr 9 at 17:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Could you please make a compilable minimal working example (MWE) that includes the documentclass and the relevant packages? Also the screenshot you include doesn't mach the code you show. – leandriis Apr 9 at 17:03
  • Regarding your alignment isue you might want to use \renewcommand{\tabularxcolumn}[1]{m{#1}} in combination with the original X type column approach as shown in this very closely related question: [Vertical alignment in tabularx X column type]tex.stackexchange.com/q/113020/134144() – leandriis Apr 9 at 17:08
  • Yes, I copied the wrong code from another table. Now is the correct one. – Fernando García Sanz Apr 9 at 17:11
  • It all worked with your solution @leandriis. Thanks a lot! – Fernando García Sanz Apr 9 at 17:13
  • The row colours overflow into the margin. – Bernard Apr 9 at 17:42
0

like this?

enter image description here

\documentclass{article}
\usepackage{tabularx}
\usepackage[table]{xcolor}

\begin{document}

{
\rowcolors{1}{blue!50!white!60}{blue!30!white!70}
\setlength{\arrayrulewidth}{1mm}
\setlength{\tabcolsep}{18pt}
\renewcommand\tabularxcolumn[1]{m{#1}}              % <---
\begin{tabularx}{\linewidth}{|m{0.3\linewidth}|X|}  % <---
\hline
ID              & GUIDEME-FR-FUNC-001 \\
TITLE           & Functions Start Over \\
AUTHOR          & IBM CIO\\
CREATION DATE   & 25-09-2018 \\
SOURCE          & GUIDEME-FR-FUNC-001 \\
SUBSYSTEM       & Functions \\
TYPE            & Functional \\
PRIORITY        & High \\
STATUS          & Approved \\
DESCRIPTION     & The system shall permit users to start over and look for another room \\
TEST PLAN       & Check if it is possible to go back to the main page once instructions have been displayed \\
\hline
\end{tabularx}
}
\end{document}

or with more space above and below cells' contents:

enter image description here

\documentclass{article}
\usepackage{cellspace,               % <--- for additional space above/below cells' content
            tabularx}                % <---
\setlength\cellspacetoplimit{4pt}    % <---
\setlength\cellspacebottomlimit{4pt} % <--- 
\addparagraphcolumntypes{X}          % <---
\usepackage[table]{xcolor}

\begin{document}

{
\rowcolors{1}{blue!50!white!60}{blue!30!white!70}
\setlength{\arrayrulewidth}{1mm}
\setlength{\tabcolsep}{18pt}
\renewcommand\tabularxcolumn[1]{m{#1}}
\begin{tabularx}{\linewidth}{|m{0.3\linewidth}|S{X}|} % <---
\hline
ID              & GUIDEME-FR-FUNC-001 \\
TITLE           & Functions Start Over \\
AUTHOR          & IBM CIO\\
CREATION DATE   & 25-09-2018 \\
SOURCE          & GUIDEME-FR-FUNC-001 \\
SUBSYSTEM       & Functions \\
TYPE            & Functional \\
PRIORITY        & High \\
STATUS          & Approved \\
DESCRIPTION     & The system shall permit users to start over and look for another room \\
TEST PLAN       & Check if it is possible to go back to the main page once instructions have been displayed \\
\hline
\end{tabularx}
}
\end{document}

note: in tabularx table environment had to be at least one column of X type (or its derivative). to have vertical centered text the contents of cells in the last column had to be vertical centered. this is in above examples obtained by \renewcommand\tabularxcolumn[1]{m{#1}}.

Not the answer you're looking for? Browse other questions tagged or ask your own question.