1

I have a simple table with 3 columns, which I am using as a heading for data. I have defined a custom underline rule (with custom thickness, color and depth) that I am using to underline each table entry.

The markup I am using is:

\documentclass[letterpaper,11pt]{article}
\usepackage{kpfonts}
\RequirePackage{fix-cm}
\setlength{\parskip}{\baselineskip}%
\setlength{\parindent}{0pt}%
\usepackage{xcolor}
\definecolor{smokyblack}{rgb}{0.06, 0.05, 0.03}
\definecolor{mygrey}{rgb}{0.1, 0.14, 0.12}
\definecolor{darkjunglegreen}{rgb}{0.0, 0.26, 0.15}
\usepackage[
top    = 0.608cm,
bottom = 1.1cm,
left   = 1.20cm,
right  = 1.10cm]{geometry}
\usepackage{titlesec}
\usepackage{ulem}
\renewcommand{\ULdepth}{5.8pt}
\renewcommand{\ULthickness}{1.35pt} 
\makeatletter 
\newcommand\semiLarge{\@setfontsize\semiLarge{13.22}{17.38}}
\makeatother
\newcommand{\greenuline}[1]{{\color{darkjunglegreen}\uline{{\color{black}#1}}}}
\titleformat{\section}
{\normalfont\Large\bfseries}{\thesection}
{1em}{}[\color{darkjunglegreen}{\titlerule[2pt]}]
\titlespacing\section{0pt}{1pt plus 4pt minus 2pt}{-3pt plus 2pt minus 2pt}

\begin{document}
\sloppy
\begin{tabular*}{\linewidth}{@{}l@{\extracolsep{\fill}}r@{}}
\textbf{\LARGE \textcolor{mygrey}{REAL NAME}}  & \large{[email protected]}\\
\colorbox{mygrey!11}{\textbf{\semiLarge \textcolor{smokyblack}{Employed Professional}}} &  \large{555-555-5555 - New York, NY}
\end{tabular*}

\section*{Section Heading}

\begin{tabular} {@{}p{6cm} p{8cm} p{7cm}}
\large{\textbf{\greenuline{Category}}} & \large{\textbf{\greenuline{Word}}} & \large{\textbf{\greenuline{Much Longer word}}}
\end{tabular}   

\end{document}

It produces output that looks like this:

enter image description here

Everything is working as intended at present. I would like to center each table entry in the column, and have my underline rule fill the width of the table column, as portrayed in the following picture:

enter image description here

What is the simplest solution to this problem?

3
  • Are the shown words column headers that you want to be horizontally centered while keeping the following entries of each column left aligned or do you want to horizontally center all entries of the table?
    – leandriis
    Dec 23, 2019 at 18:35
  • Are you aware that your table is a lot wider than the text width?
    – leandriis
    Dec 23, 2019 at 18:36
  • @leandriis I only want the words shown to be centered, I am using another table for other entries and will be keeping them centered. When I was last working on this, the table width was the result of tweaking until I got the visual result I wanted. Dec 23, 2019 at 18:39

2 Answers 2

1

With the help of \cmidrule from the booktabs package and tabular* to make sure the table stays within the text width. The line thickness can be ontrolled using the optional argument of \cmidrule.

enter image description here

\documentclass[letterpaper,11pt]{article}
\usepackage{kpfonts}
\RequirePackage{fix-cm}
\setlength{\parskip}{\baselineskip}%
\setlength{\parindent}{0pt}%
\usepackage[table]{xcolor}
\definecolor{smokyblack}{rgb}{0.06, 0.05, 0.03}
\definecolor{mygrey}{rgb}{0.1, 0.14, 0.12}
\definecolor{darkjunglegreen}{rgb}{0.0, 0.26, 0.15}
\usepackage[
top    = 0.608cm,
bottom = 1.1cm,
left   = 1.20cm,
right  = 1.10cm]{geometry}
\usepackage{titlesec}
\usepackage{ulem}
\renewcommand{\ULdepth}{5.8pt}
\renewcommand{\ULthickness}{1.35pt} 
\makeatletter 
\newcommand\semiLarge{\@setfontsize\semiLarge{13.22}{17.38}}
\makeatother
\newcommand{\greenuline}[1]{{\color{darkjunglegreen}\uline{{\color{black}#1}}}}
\titleformat{\section}
{\normalfont\Large\bfseries}{\thesection}
{1em}{}[\color{darkjunglegreen}{\titlerule[2pt]}]
\titlespacing\section{0pt}{1pt plus 4pt minus 2pt}{-3pt plus 2pt minus 2pt}

\usepackage{booktabs}
\usepackage{array}
\usepackage{calc}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\begin{document}
\sloppy
\begin{tabular*}{\linewidth}{@{}l@{\extracolsep{\fill}}r@{}}
\textbf{\LARGE \textcolor{mygrey}{REAL NAME}}  & \large{[email protected]}\\
\colorbox{mygrey!11}{\textbf{\semiLarge \textcolor{smokyblack}{Employed Professional}}} &  \large{555-555-5555 - New York, NY}
\end{tabular*}

\section*{Section Heading}
\arrayrulecolor{darkjunglegreen}

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}*{3}{C{0.3\textwidth-2\tabcolsep}}}
\large\textbf{Category} & \large\textbf{Word} & \large\textbf{Much Longer word}\\
\cmidrule[1pt](r){1-1} \cmidrule[1pt](lr){2-2} \cmidrule[1pt](l){3-3}
\end{tabular*}   

\end{document}
2
  • Wow, very different from how I was attempting to do it, thank you. Just wanted to check if there is an error in your answer, you say the line thickness can be controlled using the optional argument \cmidrule, is there something missing after that? Dec 23, 2019 at 18:50
  • Oh, nevermind I figured it out. Dec 23, 2019 at 18:53
1

Instead of using p columns, one can set the width using \makebox.

BTW< \large does not have arguments. It is a switch and should go inside braces.

\documentclass[letterpaper,11pt]{article}
\usepackage{kpfonts}
\RequirePackage{fix-cm}
\setlength{\parskip}{\baselineskip}%
\setlength{\parindent}{0pt}%
\usepackage{xcolor}
\definecolor{smokyblack}{rgb}{0.06, 0.05, 0.03}
\definecolor{mygrey}{rgb}{0.1, 0.14, 0.12}
\definecolor{darkjunglegreen}{rgb}{0.0, 0.26, 0.15}
\usepackage[
top    = 0.608cm,
bottom = 1.1cm,
left   = 1.20cm,
right  = 1.10cm]{geometry}
\usepackage{titlesec}
\usepackage{ulem}
\renewcommand{\ULdepth}{5.8pt}
\renewcommand{\ULthickness}{1.35pt} 
\makeatletter 
\newcommand\semiLarge{\@setfontsize\semiLarge{13.22}{17.38}}
\makeatother
\newcommand{\greenuline}[1]{{\color{darkjunglegreen}\uline{{\color{black}#1}}}}
\titleformat{\section}
{\normalfont\Large\bfseries}{\thesection}
{1em}{}[\color{darkjunglegreen}{\titlerule[2pt]}]
\titlespacing\section{0pt}{1pt plus 4pt minus 2pt}{-3pt plus 2pt minus 2pt}

\begin{document}
\sloppy
\begin{tabular*}{\linewidth}{@{}l@{\extracolsep{\fill}}r@{}}
\textbf{\LARGE \textcolor{mygrey}{REAL NAME}}  & \large{[email protected]}\\
\colorbox{mygrey!11}{\textbf{\semiLarge \textcolor{smokyblack}{Employed Professional}}} &  \large{555-555-5555 - New York, NY}
\end{tabular*}

\section*{Section Heading}

\begin{tabular*}{\textwidth} {@{\extracolsep{\fill}}lll@{}}
\textbf{\large\greenuline{\makebox[6cm]{Category}}} & \textbf{\large\greenuline{\makebox[6cm]{Word}}} 
  & \textbf{\large\greenuline{\makebox[6cm]{Much Longer word}}}
\end{tabular*}   

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .