9

Question

I want a table with little icons on the left and corresponding descriptive text on the right. However, LaTeX seems to make this as painful as getting your teeth pulled out, and my current attempt is shown below.

How to fix...

  1. No space between table and paragraph above and below it
  2. Icons vertically misaligned, hence clashing with paragraph above.
  3. Icons column far wider than needed

Output

enter image description here

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse feugiat, neque ut scelerisque tincidunt, leo est lobortis tortor, sit amet fringilla nisl augue at nisi. Pellentesque dapibus, turpis in eleifend pharetra, quam tortor dignissim lectus, sed bibendum sapien purus ac mauris. Maecenas mi nibh, porta non dignissim nec, tincidunt non arcu. Ut dapibus sagittis est non tempor. Aliquam erat volutpat. Donec sed arcu purus, vitae malesuada erat. Nunc eget diam nisi, at pretium leo. Sed at semper magna. Nam sit amet est nisi, in aliquet eros. 

\begin{tabular}{m{.1\textwidth}@{\extracolsep{5mm}} p{.75\textwidth} }
    \includegraphics[scale=0.05]{Figures/eps.png} & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse feugiat, neque ut scelerisque tincidunt, leo est lobortis  \\
    \includegraphics[scale=0.05]{Figures/eps.png} & Pellentesque dapibus, turpis in eleifend pharetra, quam tortor dignissim lectus, sed bibendum sapien purus ac mauris  \\
    \includegraphics[scale=0.05]{Figures/eps.png} & Ut dapibus sagittis est non tempor. Aliquam erat volutpat. Donec sed arcu purus, vitae malesuada erat. Nunc eget diam nisi, at pretium leo. \\
\end{tabular}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse feugiat, neque ut scelerisque tincidunt, leo est lobortis tortor, sit amet fringilla nisl augue at nisi. Pellentesque dapibus, turpis in eleifend pharetra, quam tortor dignissim lectus, sed bibendum sapien purus ac mauris. Maecenas mi nibh, porta non dignissim nec, tincidunt non arcu. Ut dapibus sagittis est non tempor. Aliquam erat volutpat. Donec sed arcu purus, vitae malesuada erat. Nunc eget diam nisi, at pretium leo. Sed at semper magna. Nam sit amet est nisi, in aliquet eros. 
10

The following might address your needs:

enter image description here

\documentclass{article}
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
\usepackage[export]{adjustbox}% http://ctan.org/pkg/adjustbox
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse feugiat, 
neque ut scelerisque tincidunt, leo est lobortis tortor, sit amet fringilla 
nisl augue at nisi.

\renewcommand{\tabularxcolumn}[1]{m{#1}}%
\noindent\begin{tabularx}{\linewidth}{@{\hspace*{\parindent}}l X@{}}
  \includegraphics[width=25pt,valign=c]{example-image-a} &
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse feugiat, 
    neque ut scelerisque tincidunt, leo est lobortis  \\
  \includegraphics[width=25pt,valign=c]{example-image-b} & 
    Pellentesque dapibus, turpis in eleifend pharetra, quam tortor dignissim 
    lectus, sed bibendum sapien purus ac mauris  \\
  \includegraphics[width=25pt,valign=c]{example-image-c} & 
    Ut dapibus sagittis est non tempor. Aliquam erat volutpat. Donec sed arcu 
    purus, vitae malesuada erat. Nunc eget diam nisi, at pretium leo.
\end{tabularx}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse feugiat, 
neque ut scelerisque tincidunt, leo est lobortis tortor, sit amet fringilla 
nisl augue at nisi.
\end{document}

Some remarks:

  • Vertical alignment of table entries are obtained using an m-column specification. Note that the right column is vertically centred with respect to the left (not the other way around/like you had before).
  • In addition to the above m-column specification, the anchor point for the left-hand icons are set with the valign=c key-value that is exported from adjustbox. Alternatively, graphicx's \raisebox{-.5\height}{..} should also work.
  • I used tabularx to obtain a table where I don't have to worry about the width of the final column. Sure, you can fix it with a regular m-column, but the X-column makes it fit within the text block boundary without hassle. The default X-column specification is p{..}, which I've updated to m{..} using the \renewcommand{\tabularxcolumn}[1]{...} update. If this is specific to a certain location within your file, you might want to group this to localize the scope.
  • Some horizontal tweaking might be required to achieve something to your liking; I've just showed one possible view.

Caveat: This will not break across pages. For that, you may find ltxtable helpful.

2
  • Thanks - any way to control how much the table is indented on the left?
    – mchen
    May 31 '13 at 17:45
  • @MiloChen: Yes. While I've added \noindent before the tabularx environment, you can update @{\hspace*{<len>}} to whatever length you want. I used \parindent which is the default paragraph indent, hence the horizontal alignment with the other paragraphs. The ending @{} makes the table line up perfectly with the right end of the text block. If you wish to have an indent on the right side as well, use @{\hspace*{<len>}} as well, where you set <len>.
    – Werner
    May 31 '13 at 17:47

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.