0

I am using tabular to create a table in latex. You can see my work below:

In this I need to change the font for the 2nd row to Courier font.

How can I achieve this. I do not want to change the font for the rest of the rows, specially the header.

Thanks!

My Work:

\documentclass{article}
\usepackage{multirow}
\usepackage{xcolor}
\usepackage{color, colortbl}
\begin{document}

\begin{table}[h]
    \centering
    \small
    \begin{tabular}{|c|c|l|l|}
        \hline 
        \rowcolor[HTML]{CACFD2} 
        \textbf{Header 1} & \textbf{Header 2} & \textbf{Header 3} \\ \hline 
        \multirow{2}{*}{A}  & Col2 & ABCDE (Row1) \\ \cline{2-3}
        & Col2 & ABCDE (Row2) \\    \hline 
        B                   & Col2 & ABCDE (Row3)\\ \hline 
    \end{tabular}
\end{table}

\end{document}

Adding \texttt at row level didn't work. See below

\documentclass{article}
\usepackage{multirow}
\usepackage{xcolor}
\usepackage{color, colortbl}
\begin{document}

\begin{table}[h]
    \centering
    \small
    \begin{tabular}{|c|c|l|l|}
        \hline 
        \rowcolor[HTML]{CACFD2} 
        \textbf{Header 1} & \textbf{Header 2} & \textbf{Header 3} \\ \hline 
        \texttt{\multirow{2}{*}{A}  & Col2 & ABCDE (Row1)} \\ \cline{2-3}
        \texttt{\& Col2 & ABCDE (Row2)} \\    \hline 
        \texttt{\B                   & Col2 & ABCDE (Row3)}\\ \hline 
    \end{tabular}
\end{table}

\end{document}

Adding \texttt at every cell level worked.

\documentclass{article}
\usepackage{multirow}
\usepackage{xcolor}
\usepackage{color, colortbl}
\begin{document}

\begin{table}[h]
    \centering
    \small
    \begin{tabular}{|c|c|l|l|}
        \hline 
        \rowcolor[HTML]{CACFD2} 
        \textbf{Header 1} & \textbf{Header 2} & \textbf{Header 3} \\ \hline 
        \multirow{2}{*}{\texttt{A}}  & \texttt{Col2} & \texttt{ABCDE (Row1)} \\ \cline{2-3}
        & \texttt{Col2} & \texttt{ABCDE (Row2)} \\    \hline 
        \texttt{B}                   & \texttt{Col2} & \texttt{ABCDE (Row3)}\\ \hline 
    \end{tabular}
\end{table}

\end{document}

Output

enter image description here

  • Please extend your piece of code to a MWE. What engine are you using? – TeXnician Mar 17 '17 at 16:32
  • "I need to change the font". Would this be the font size, weight, shape, or family? Or all of the above? Or something completely different maybe? Don't expect to find accomplished mind readers on this site. I'm afraid you'll be sorely disappointed if you do... – Mico Mar 17 '17 at 16:37
  • 1
    You can place your font commands inside each cell of the tabular. – Werner Mar 17 '17 at 16:40
  • I tried to use \texttt at the row level, it didn't work. But if I use it before begin{tabular} then it works. – TechJ Mar 17 '17 at 16:47
  • please show us what did not work. You will get much more help here if you extend your code to make a complete document that people here can just cut and paste locally and compile. – Thruston Mar 17 '17 at 17:11
1

Just use \texttt separately around each cell. a table cell is a group like {...} so there is no natural way to start a font change in the first cell in a row and make it last for the whole row.

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.