Tx · LaTeX & TikZ

How to Remove Photo Padding in moderncv Classic

Published By the 9to5Science editorial team

At a glance

  1. 1. Find the frame gap

    In classic style, the gap between the portrait and its border is controlled by TeX's fboxsep length.

  2. 2. Set the inset to zero

    Set fboxsep to 0pt locally around makecvtitle to remove the gap without changing other framed content.

  3. 3. Adjust the border

    The second optional argument of photo sets the border thickness; use 0pt if you also want to remove the border.

  4. 4. Check the image file

    If white space remains, crop it from the image itself; LaTeX cannot remove margins baked into the file with fboxsep.

In the classic style, the photo can appear to have padding because TeX leaves an inset between the image and its frame. You can remove that inset by setting \fboxsep to 0pt when \makecvtitle is typeset. This keeps the change local rather than affecting every framed box in your document.

The photo command’s second optional argument controls the frame thickness, not the padding. You can set that argument to 0pt as well if you want the portrait without a border.

Remove the gap but keep the border

Set \fboxsep immediately around \makecvtitle:

\documentclass[11pt,a4paper]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{blue}
\usepackage{mwe} % supplies the example-image-a test image

\name{Jane}{Doe}
\photo[64pt][0.4pt]{example-image-a}

\begin{document}
{\setlength{\fboxsep}{0pt}\makecvtitle}
\end{document}

The braces group the setting: \fboxsep is zero while the title is built, then returns to its previous value. The photo still has a 0.4pt border, but the extra inset between that border and the image is removed. The mwe package is included only to provide a sample image; replace example-image-a with your portrait file.

Remove both the gap and border

Change the photo command’s second optional argument to 0pt:

\photo[64pt][0pt]{portrait.jpg}

The first optional argument sets the photo height, and the second sets the frame width. With no frame, there is no border or frame inset to show. Keeping the local \fboxsep setting is harmless, but it matters when a frame is drawn.

If padding remains

\fboxsep only changes spacing created by TeX around a framed object. It cannot crop blank pixels or white margins that are already part of the image file. To check, open the image separately or temporarily use a contrasting background behind it. If the empty margin appears in the image itself, crop the source image before adding it to the CV.

Also distinguish photo padding from space elsewhere in the header. If the portrait is tight against its border but the header still looks too spacious, the issue is likely the title layout or image dimensions, not \fboxsep.

Common mistakes

  • Changing \fboxrule instead of \fboxsep: \fboxrule changes the border thickness; \fboxsep changes the inset between border and content.
  • Setting the photo frame argument to zero to remove only the gap: That removes the border. Keep a nonzero frame width and set \fboxsep to zero if you want the border to remain.
  • Changing \fboxsep globally: This can affect other boxes in the document. Group the setting around \makecvtitle unless you intentionally want it to apply more broadly.
  • Expecting LaTeX to remove margins in the file: Crop the source image if the blank area is part of the image itself.

References

  1. moderncv — A modern curriculum vitae class (CTAN)

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.