1

I have created a new command using colorbox as follow:

\newcommand{\resheading}[1]{{\small \colorbox{mygrey}{\begin{minipage}{0.975\textwidth}{\textbf{#1 \vphantom{p\^{E}}}}\end{minipage}}}}

This is how it looks: enter image description here

Is there a way to increase the spacing between resheading and the bullet point? Any help is greatly appreciated.

  • Also, a newline is just too much – subtleseeker Jul 6 at 13:51
2

The following adds 5pt of additional vertical space:

\documentclass[]{article}

\overfullrule5pt
\usepackage{xcolor}

\definecolor{mygrey}{gray}{.85}

\newsavebox\resheadingbox
\newcommand{\resheading}[1]
  {%
    \sbox\resheadingbox
      {%
        \colorbox{mygrey}
          {%
            \begin{minipage}{\dimexpr\linewidth-2\fboxsep\relax}
              \small
              \bfseries
              \strut#1\strut
            \end{minipage}%
          }%
      }%
    \dp\resheadingbox\dimexpr\dp\resheadingbox+5pt\relax
    \usebox\resheadingbox
  }

\begin{document}
\noindent\resheading{something}
something else
\end{document}

How it works:

  1. we set the results of the \colorbox command into a box, it is not directly printed (\sbox\resheadingbox{...}).
  2. we enlarge this box by 5pt to the bottom (\dp\resheadingbox=\dimexpr\dp\resheadingbox+5pt\relax, I left out the optional =), for this enlargement TeX pads whitespace.
  3. we output the contents of the box register (\usebox\resheadingbox)

I also changed the width of your minipage, such that the \colorbox will be as wide as possible without sticking into the margin (a \colorbox adds an \fboxsep on both sides as padding, we use the width of a full line minus those 2\fboxsep). Also I used \strut as vertical padding inside the \colorbox instead of your \vphantom{...} construct, a \strut has zero width and the height and depth such that it is as big as your fontsize.

enter image description here

  • It works exactly as needed! Could you explain what is happening here? For what I can understand is that you added a box to create some whitespace. I am new to LaTeX. – subtleseeker Jul 6 at 14:16
  • @subtleseeker I've added a small explanation. Anything else you don't understand? – Skillmon Jul 6 at 14:31
  • Thanks, this helped! – subtleseeker Jul 6 at 14:35
  • To whomever downvoted my answer: Do you want to explain why you downvoted this and what you want me to improve? – Skillmon Jul 7 at 6:38
2

I propose this simple code, based on the shaded* environment from the framed package:

\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry}

\usepackage[svgnames]{xcolor}
\usepackage{framed}
\colorlet{shadecolor}{Gainsboro!50! Lavender}

\newcommand{\resheading}[1]
  {%
  \setlength{\OuterFrameSep}{1pt}
  \setlength{\FrameSep}{5pt}
\begin{shaded*}
\noindent\small\bfseries\hspace*{-2pt}#1
     \end{shaded*}\noindent }%

\begin{document}

Blah blah blah… blah blah blah…
\resheading{INDUSTRIAL TRAINING AND MINOR PROJECTS}%
Some text. Some more text.

\end{document} 

enter image description here

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.