1

I have a table with entries in the first column to be aligned to the left of the page. I have a colorbox around one of the entries, which is causing the text to be slightly indented. Is there a way to prevent this?

A picture showing the problem:

enter image description here

And the markup I am using:

\documentclass[letterpaper,11pt]{article}
\usepackage{kpfonts}
\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}
\makeatletter 
\newcommand\semiLarge{\@setfontsize\semiLarge{13.22}{17.38}}
\begin{document}
    \sloppy
    \begin{tabular*}{\linewidth}{@{}l@{\extracolsep{\fill}}r@{}}
        \textbf{\LARGE \textcolor{mygrey}{REAL NAME}}  & \large{email@realemail.com}\\
        \colorbox{mygrey!11}{\textbf{\semiLarge \textcolor{smokyblack}{Employed Professional}}} &  \large{555-555-5555 - New York, NY}
    \end{tabular*}
\end{document}
4
  • You can either set \fboxsep to 0pt, or use \hspace(-\fboxsep} to compensate. Dec 23 '19 at 19:30
  • @JohnKormylo thank you, I did not know about the fboxsep command, I just used it and this removed the indentation, but it also raised the vertical height of the box. Is there a way to remove the indentation without adjusting the height? Dec 23 '19 at 19:35
  • Did you try the negative \hspace yet. Dec 23 '19 at 19:47
  • @JohnKormylo Negative hspace worked a treat, thank you. If you want to make your comment an answer I will accept it. Dec 23 '19 at 19:53
2

The \colorbox macro from xcolor adds an \fboxsep border (actually it uses \fbox). This compensates for the excess horizontal space.

\documentclass[letterpaper,11pt]{article}
\usepackage{kpfonts}
\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}
\makeatletter 
\newcommand\semiLarge{\@setfontsize\semiLarge{13.22}{17.38}}
\begin{document}
    \sloppy
    \begin{tabular*}{\linewidth}{@{}l@{\extracolsep{\fill}}r@{}}
        \textbf{\LARGE \textcolor{mygrey}{REAL NAME}}  & \large{email@realemail.com}\\
        \hspace{-\fboxsep}\colorbox{mygrey!11}{\textbf{\semiLarge \textcolor{smokyblack}{Employed Professional}}} &  \large{555-555-5555 - New York, NY}
    \end{tabular*}
\end{document}

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.