2

I am having troubles making subfloat captions wider than the picture it describes. Here is a MWE:

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{subfig}
\begin{document}

\begin{figure}
\centering
\subfloat[Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec porttitor, arcu quis interdum ultricies, est mauris eleifend est, sit amet ornare diam odio id ante. Donec mattis finibus hendrerit. Etiam rhoncus nunc nec lectus tincidunt, nec rhoncus erat convallis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer elementum neque quis arcu pellentesque accumsan. Proin quis felis sollicitudin dolor blandit sodales sed ut nunc. Cras euismod leo turpis, nec molestie diam placerat et. In feugiat pulvinar dolor vel posuere. Nulla in dolor non ligula accumsan sollicitudin non tincidunt velit. Fusce auctor tellus tortor, nec commodo lectus interdum aliquet. Maecenas in scelerisque magna. In rhoncus est eget sagittis eleifend. Nulla aliquet eleifend purus, vel faucibus sem gravida porttitor. Nullam pellentesque velit non nulla molestie, quis ultricies dolor fermentup]{
\includegraphics[width=0.2\textwidth]{uefaeuro16.png}
}
\hspace{0.3\textwidth}
\subfloat[Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec porttitor, arcu quis interdum ultricies, est mauris eleifend est, sit amet ornare diam odio id ante. Donec mattis finibus hendrerit. Etiam rhoncus nunc nec lectus tincidunt, nec rhoncus erat convallis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer elementum neque quis arcu pellentesque accumsan. Proin quis felis sollicitudin dolor blandit sodales sed ut nunc. Cras euismod leo turpis, nec molestie diam placerat et. In feugiat pulvinar dolor vel posuere. Nulla in dolor non ligula accumsan sollicitudin non tincidunt velit. Fusce auctor tellus tortor, nec commodo lectus interdum aliquet. Maecenas in scelerisque magna. In rhoncus est eget sagittis eleifend. Nulla aliquet eleifend purus, vel faucibus sem gravida porttitor. Nullam pellentesque velit non nulla molestie, quis ultricies dolor fermentu]{
\includegraphics[width=0.2\textwidth]{uefaeuro16.png}
}
\end{figure}
\end{document}

and the output it gives: subfloat width Basically I'd like to have the captions using the extra space available, like when the picture is alone in a figure environment figure width. I tried to enclose the subfloat into minipage but it didn't produce the expected result.

  • Parboxing the caption doesnt work. Manipulating \linewidth doesnt work either. – MaestroGlanz Jun 6 '16 at 8:43
1

I just added

  • the package grffile, because my logo-name contains _
  • a line

    \captionsetup[subfigure]%
    %{margin=-1cm}
    {width=7cm}
    % choose width or margin
    
  • \hspace*{1cm} right before \includegraphics

I admit, you have to play with either margin or width in the captionsetup, but you can have a subfloat caption broader than the image:

enter image description here

This is the code:

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{subfig, grffile}
\captionsetup[subfigure]%
%{margin=-1cm}
{width=7cm}
\begin{document}

\begin{figure}
\centering
\subfloat[Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec porttitor, arcu quis interdum ultricies, est mauris eleifend est, sit amet ornare diam odio id ante. Donec mattis finibus hendrerit. Etiam rhoncus nunc nec lectus tincidunt, nec rhoncus erat convallis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer elementum neque quis arcu pellentesque accumsan. Proin quis felis sollicitudin dolor blandit sodales sed ut nunc. Cras euismod leo turpis, nec molestie diam placerat et. In feugiat pulvinar dolor vel posuere. Nulla in dolor non ligula accumsan sollicitudin non tincidunt velit. Fusce auctor tellus tortor, nec commodo lectus interdum aliquet. Maecenas in scelerisque magna. In rhoncus est eget sagittis eleifend. Nulla aliquet eleifend purus, vel faucibus sem gravida porttitor. Nullam pellentesque velit non nulla molestie, quis ultricies dolor fermentup]{
\hspace*{1cm}\includegraphics[width=0.2\textwidth]{426px-Uefa_Euro_2016_logo.png}
}
\hspace{0.3\textwidth}
\subfloat[Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec porttitor, arcu quis interdum ultricies, est mauris eleifend est, sit amet ornare diam odio id ante. Donec mattis finibus hendrerit. Etiam rhoncus nunc nec lectus tincidunt, nec rhoncus erat convallis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer elementum neque quis arcu pellentesque accumsan. Proin quis felis sollicitudin dolor blandit sodales sed ut nunc. Cras euismod leo turpis, nec molestie diam placerat et. In feugiat pulvinar dolor vel posuere. Nulla in dolor non ligula accumsan sollicitudin non tincidunt velit. Fusce auctor tellus tortor, nec commodo lectus interdum aliquet. Maecenas in scelerisque magna. In rhoncus est eget sagittis eleifend. Nulla aliquet eleifend purus, vel faucibus sem gravida porttitor. Nullam pellentesque velit non nulla molestie, quis ultricies dolor fermentu]{
\hspace*{1cm}\includegraphics[width=0.2\textwidth]{426px-Uefa_Euro_2016_logo.png}
}
\end{figure}
\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.