Graphics, Figures & TablesCaptions: Tricky Underlining

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
generator
Posts: 9
Joined: Sat Apr 03, 2010 5:56 am

Captions: Tricky Underlining

Post by generator »

I'm attempting to create custom float captions (for custom floats). Ordinarily, I might use a regular Figure to display a figure. In this case, the caption might display as:
Figure 1: A figure.
However, I want to underline the portion to the left of the colon. This would look like:

Figure 1: A figure.

I've come close to doing this. I can use

Code: Select all

\floatname{ColumnFigure}{\underline{Figure}}
which underlines the word "Figure".

Then, I can also use

Code: Select all

\renewcommand{\theColumnFigure}{\underline{\arabic{ColumnFigure}}}
which underlines the 1. I'd like to underline everything except the caption description. Can someone please help?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Captions: Tricky Underlining

Post by sommerfee »

For underlining captions see http://www.latex-community.org/forum/vi ... 00&start=0

Without underlining the caption text nor the colon, that gives something like:

Code: Select all

\documentclass{article} 
\usepackage{ulem}
\usepackage{caption}[2007/09/01] % needs v3.1 or newer

\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 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}
generator
Posts: 9
Joined: Sat Apr 03, 2010 5:56 am

Captions: Tricky Underlining

Post by generator »

I've found a way to do this without using the "ulem" package; use math mode, and "underline" some "text" in math mode.

Code: Select all

\documentclass{article} 
\usepackage{caption}[2007/09/01] % needs v3.1 or newer

%THE NEWLY REDONE TEXT FOLLOWS:
\DeclareCaptionLabelFormat{underlcap}{$\underline{\text{#1 #2}}$}
\captionsetup[figure]{labelformat=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}
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Captions: Tricky Underlining

Post by localghost »

generator wrote:I've found a way to do this without using the "ulem" package; use math mode, and "underline" some "text" in math mode. […]
Then please mark the topic accordingly as written in Section 3 of the Board Rules (to be read before posting). This applies also to all your former requests. Please keep that in mind for the future so that further reminders will not be necessary.


Thorsten
Post Reply