[Tex/LaTex] Table example made in Google Docs – how to make (would one make) this in LaTeX

formattingtablestabularx

edit -> the emphasis on Google Docs might be a bit much, basically it's just a little table thing, it's not something unique to Google Docs thats just what I happened to use to make this.

I made this in Google Docs, and I was going to do this in LaTeX but I can't seem to get this table made, I'm not even sure if tables the proper name for it. Perhaps there's another name / environment for this kind of thing that I'm unaware of.

enter image description here

So how would you go about making that in LaTeX?

Thanks!


I've looked at some of the other links on here, a few things are coming up about converting google docs but there doesn't seem to be anything solid. I can't download HTML and use Pandoc because there's CSS in there as well…

Best Answer

It's straightforward to create such a table using the xcolor and colortbl packages. You didn't indicate the preferred width of the table, so I've assumed it should be as wide as the text block.

enter image description here

\documentclass{article}
\usepackage[table,svgnames]{xcolor}
\usepackage{tabularx,lipsum,ragged2e}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash}X} % allow hyphenation
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{|Y|Y|}
\hline
\rowcolor{LightBlue} Something & Another\\
\hline
\lipsum*[2] & \lipsum*[4]\\
\hline
\rowcolor{LightBlue} Example & Demonstration\\
\hline
\lipsum*[2] & \lipsum*[4]\\
\hline
\end{tabularx}
\end{document}

Addendum -- As @barbarabeeton has pointed out in a comment, the horizontal lines in the preceding table are spaced very narrowly and created a cramped look. One way to improve the table's look is to insert (typographic) struts. Insert a "top" strut if there's an \hline immediately ahead of the material, insert a "bottom" strut if there's an \hline immediately after the material, and insert both a top and a bottom strut if the material is in a header row. (For more on typographic struts in a LaTeX document see, e.g., https://tex.stackexchange.com/a/50355/5001.)

enter image description here

\documentclass{article}
\usepackage[table,svgnames]{xcolor}
\usepackage{tabularx,lipsum,ragged2e}
\newcommand\sometext{Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi auctor lorem non justo. Nam lacus libero, pretium at, lobortis vitae, ultricies et, tellus. Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet magna, vitae ornare odio metus a mi.}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash}X} % allow hyphenation

%% From the article "Correct spacing for tables and arrays" 
%% by Claudio Beccari, p. 10 of TeX and TUG News 1993 (Vol. 2, No. 3). 
\newcommand\T{\rule{0pt}{2.6ex}}       % Top strut
\newcommand\B{\rule[-1.2ex]{0pt}{0pt}} % Bottom strut
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{|Y|Y|}
\hline
\rowcolor{LightBlue} Something & Another\T\B \\
\hline
\T\sometext & \sometext\B \\
\hline
\rowcolor{LightBlue} Example & Demonstration\T\B \\
\hline
\T\sometext & \sometext\B \\
\hline
\end{tabularx}
\end{document}