Text Formattinghighlight keywords as a column specification in a tabular

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
eimund
Posts: 6
Joined: Mon Jul 20, 2009 1:09 pm

highlight keywords as a column specification in a tabular

Post by eimund »

Hi,

I'm trying to make a tabular which is able to highlight keywords inside a tabular in the same fashion as the listings package does. I want to give this as a column specification to the tabular, which is challenging since seems that the listings doesn't recognize LaTeX macroes inside it's enviroment. My attempt was like this

Code: Select all

\usepackage{listings}
\newsavebox{\boxname}
\lstset{keywords={ref, class, abstract}}

\begin{document}
\begin{tabular}{|c|>{\begin{lrbox}{\boxname}}c<{\end{lrbox}\lstinline{\unhbox\boxname}}|}
A  & class c\\
\end{tabular}
\end{document}
Does anyone have an idea how to achieve this? I don't like the solution where you have to use the \lstinline for each cell in the column.

Thanks,
Eimund

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

Post Reply