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
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
Post Reply