Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm new to latex but I'm trying to learn and am piecing together various pieces of code from different postings, so I apologize if this code is "messy".

In a table, I would like to have the widths of the columns custom-defined, and I would also like to make specific rows bold. I had found out from another posting how to make specific rows bold, but now when I add code to make my column custom-width and right-justified, the bold-faced row part doesn't work anymore. Here is an example, where you see both situations:

\documentclass{scrreprt}

%for adding the ability to make entire rows bold:
\usepackage{array}
\newcolumntype{$}{>{\global\let\currentrowstyle\relax}}
\newcolumntype{^}{>{\currentrowstyle}}
\newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
  #1\ignorespaces
}

%define right justified column with custom width
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}

\begin{document}
\begin{table}[ht]

\begin{tabular}{$p{2.1cm} ^p{1.6cm} R{1.5cm} R{2cm}}
\hline
header1 & header2 & header3 & header4\\
\hline
a & b & c & d\\
\rowstyle{\bfseries}
e & f & g & h\\
\hline
\end{tabular}
\end{table}
\end{document}

enter image description here

As you can see, when I use the raggedleft column type (to make it right-justified), the bold-face doesn't work.

Any ideas as to how I can get these two to work together?

share|improve this question
    
Welcome to TeX.SE. –  Peter Grill Apr 26 '12 at 2:33

1 Answer 1

up vote 5 down vote accepted

You need to include the \currentrowstyle in the R column type:

\newcolumntype{R}[1]{>{\currentrowstyle\raggedleft\arraybackslash}p{#1}}

Making this change yields the complete row in bold:

enter image description here

share|improve this answer
    
fantastic! thank you. –  Pascal Apr 26 '12 at 2:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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