1

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...

  • 2
    What have you tried so far in LaTeX? A combination of colortbl and array packages should be able to get the job done. – Paul Gessler Feb 5 '15 at 22:23
  • hey @PaulGessler, I've tried using the tabular environment and multirow within that and there was something else (that I've forgotten). I was reading a book (which didn't give much info on tables to be fair) but said that people often use tables when they shouldn't, so I thought perhaps this was in fact called something else when created with LaTeX, a floating box environment or something idk. – baxx Feb 5 '15 at 22:26
  • I'm guessing that you're saying that you would make this using colortbl and array packages then Paul ? – baxx Feb 5 '15 at 22:27
  • You don't need multirow. Paul's suggestion would work for this - it is not an especially sophisticated design, so I'd stick to the simple solution. – cfr Feb 5 '15 at 22:39
  • OK cheers, everything kept overflowing the boxes and stuff. So how you would do this @cfr is 'combination of colortbl and array packages' ? thanks]# – baxx Feb 5 '15 at 22:41
5

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}
  • thanks a lot @Mico. For this kind of thing would you have the contents of the table (the paragraphs of text) in a separate file and 'include' (insert...) them into the table or just have it all in the same place? cheers – baxx Feb 5 '15 at 22:45
  • @user3130747 - I'd place the text directly inside the cells. – Mico Feb 5 '15 at 22:46
  • thanks a lot @Mico, this is a lot simpler than I thought it would be actually (based on some of the generated code from a latex tables generator site that I had used). cheers – baxx Feb 5 '15 at 22:49
  • 1
    i'd like to see a little more vertical clearance at least around the headings. would also improve the (tops of the) text boxes. – barbara beeton Feb 6 '15 at 17:15
  • @barbarabeeton - Thanks. I've posted an addendum that discusses how one may use typographic struts to create a more open look (while still dealing with \hlines and vertical lines). – Mico Feb 6 '15 at 20:30
3

Here's a simple approach with tabulary and xcolor.

\documentclass{article}

% FONT
\usepackage[T1]{fontenc}
\usepackage{tgheros}
\renewcommand*\familydefault{\sfdefault}

% TABLE FORMATS
\usepackage{tabulary}
\usepackage[table]{xcolor}

% Format header rows uniformly
\newcommand{\tableheader}[1]{%
    \cellcolor{cyan}\textbf{#1}%
}

% DUMMY TEXT FOR EXAMPLE
\newcommand{\cicero}{% 
    Quo usque tandem abutere, Catilina, patientia nostra? 
    quam diu etiam furor iste tuus nos eludet? 
    quem ad finem sese effrenata iactabit audacia? 
    Nihilne te nocturnum praesidium Palati, 
    nihil urbis vigiliae, 
    nihil timor populi, 
    nihil concursus bonorum omnium, 
    nihil hic munitissimus habendi senatus locus, 
    nihil horum ora voltusque moverunt?%
}



\begin{document}

\noindent
\begin{tabulary}{\linewidth}{|L|L|}
\hline
\tableheader{Something} & \tableheader{Another}\\ \hline
\cicero                 & \cicero\\ \hline
\tableheader{Example}   & \tableheader{Demonstration}\\ \hline
\cicero                 & \cicero\\ \hline
\end{tabulary}

\end{document}

enter image description here

  • You may want to explain how the L column type of the tabulary environment, which is used in your answer, differs from the X column type of the tabularx package. Having a brief explanation of this type may help (non-expert) readers form an opinion as to which environment may be best-suited to meet their typesetting needs. – Mico Feb 6 '15 at 10:28
1

Disclaimer: This is official account of Docx2Latex

We have just launched Google Docs-add on which combines the power of Latex and ease of word processors and cross Referencing too.

You can take advantage of its LaTeX code generation capabilities to get the code for any kind of table without worrying about tedious job of remembering different types of syntax for a normal table, table with merged cells, long table, table with colored background etc.

Following are some cool features (related to table) that Docx2LaTeX add-on supports.

  1. Converts normal tables.
  2. Converts long tables(spreading across multiple pages).
  3. Converts table with merged cells (row, columns or both simultaneously).
  4. Detects the cell background colors.
  5. Intelligently adjusts the widths of columns to save table from running out of right margin.

This really helps in saving time and catch up on deadlines. For more feature of add-on refer to https://tex.stackexchange.com/a/423698/159282

Add-On Link: Docx2Latex Google Docs Add-on

Watch Demo: Short Demo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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