Graphics, Figures & Tables ⇒ Underlining the Figure in the Figure
Underlining the Figure in the Figure
Hi all
I was wondering if anyone knew how to underline the figure in the figure, like
Picture is here
Figure 3.1: Picture
I've played around with latex and I can get the caption to underline but not the Figure 3.1 and then I found I can also get the number to underline but not the Figure. So basically it looks like
Figure 3.1: Picture
Anyone have any ideas? It's be much appreciated!
Thanks
I was wondering if anyone knew how to underline the figure in the figure, like
Picture is here
Figure 3.1: Picture
I've played around with latex and I can get the caption to underline but not the Figure 3.1 and then I found I can also get the number to underline but not the Figure. So basically it looks like
Figure 3.1: Picture
Anyone have any ideas? It's be much appreciated!
Thanks
Last edited by samness25 on Mon Sep 13, 2010 5:59 pm, edited 2 times in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.

Underlining the Figure in the Figure
Hi,
perhaps not the most elegant solution:
perhaps not the most elegant solution:
Code: Select all
\documentclass{article}
\usepackage{ulem}
\usepackage{caption}
\DeclareCaptionLabelFormat{underlcap}{\uline{#1 #2}}
\captionsetup[figure]{labelformat=underlcap}
\begin{document}
\begin{figure}[!ht]
\centering
\rule{3cm}{4cm}% to simulate an actual figure
\caption[test figure]{\hspace*{-7pt}\uline{\hspace*{7pt}test figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure}}
\label{fig:test}
\end{figure}
\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Underlining the Figure in the Figure
When using caption package v3.1 one can add a (tricky) \DeclareCaptionTextFormat, too, so there is no need anymore to use \uline within the caption:meho_r wrote:if I may, I'd also add to the example a custom separator definition and remove manual \hspace commands from caption:
\DeclareCaptionLabelSeparator{underlcap}{\uline{:~}}
This way there's no small gap at the separator (colon).
Code: Select all
\documentclass{article}
\usepackage{ulem}
\usepackage{caption}[2007/09/01] % needs v3.1 or newer
\DeclareCaptionLabelFormat{underlcap}{\uline{#1 #2}}
\DeclareCaptionLabelSeparator{underlcap}{\uline{:~}}
\DeclareCaptionTextFormat{underlcap}{\expandafter\uline\expandafter{\expandafter#1}}
\captionsetup[figure]{%
labelformat=underlcap,labelseparator=underlcap,textformat=underlcap}
\begin{document}
\begin{figure}[!ht]
\centering
\rule{3cm}{4cm}% to simulate an actual figure
\caption{test figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure figure}
\label{fig:test}
\end{figure}
\end{document}
Underlining the Figure in the Figure
Sorry for accidental deletion of my post. However, this solution is great and contains my suggestion, so no harm done. I'll link it to another thread about underlining since it solves the problem with more-than-one-line captions. Thanks for the solution.
Re: Underlining the Figure in the Figure
Thank you all so much! Worked perfectly 

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Underlining the Figure in the Figure
Now that the problem is obviously solved, please be so kind and mark the topic accordingly as clearly written in Section 3 of the Board Rules (to be read before posting).
Best regards
Thorsten
Best regards
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Underlining the Figure in the Figure
Wow, sorry. But it's not quite solved.
I suppose it would have been easier to have included tables in my question. The code works for figures and my partner and I have tried to rework it for tables but it has been unsuccessful, is there a different code for tables?
I suppose it would have been easier to have included tables in my question. The code works for figures and my partner and I have tried to rework it for tables but it has been unsuccessful, is there a different code for tables?
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Underlining the Figure in the Figure
This sounds very much like a solved problem. Otherwise you shouldn't use such expressions.samness25 wrote:Thank you all so much! Worked perfectly :)
You got the code from sommerfee. Just drop the optional argument for the \captionsetup command and it should work.samness25 wrote:[…] I suppose it would have been easier to have included tables in my question. The code works for figures and my partner and I have tried to rework it for tables but it has been unsuccessful, is there a different code for tables?
Finally just a general remark. If code is not working, a simple phrase like »was not successful« is not very helpful. Provide a minimal example and explain exactly what is not working and echo corresponding error messages.
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10