Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How to bold automatically the first sentence of the float caption and second sentence is normal?

\begin{figure}[t]
\centering
\caption{First sentence. Second sentence.}
\end{figure}

Output should be:

Figure 1. First sentence. Second sentence.

share|improve this question
1  
Do you use any packages influencing the caption? Which document class do you use? Please provide a complete minimal working examples. –  Marco Daniel Aug 3 '12 at 7:53
    
I did not use any influencing packages. I use article.cls –  jeecabz Aug 3 '12 at 8:15
add comment

2 Answers

up vote 5 down vote accepted

You can use the approach described in Customize text format of captions by parsing content of \@caption, namelly

\documentclass{article}
\usepackage{xstring}
\usepackage{etoolbox}
\usepackage{caption}

\captionsetup{labelfont=bf,tableposition=top}

\makeatletter
\newcommand\formatlabel[1]{%
    \noexpandarg
    \IfSubStr{#1}{.}{%
      \StrBefore{#1}{.}[\firstcaption]%
      \StrBehind{#1}{.}[\secondcaption]%
      \textbf{\firstcaption.} \secondcaption}{%
      #1}%
      }


\patchcmd{\@caption}{#3}{\formatlabel{#3}}
\makeatother

\begin{document}

\begin{figure}[t]
\centering
test test
\caption{First sentence. Second sentence.}
\end{figure}

\end{document}
share|improve this answer
    
This solution only works when your sentence ends with a (single) period. –  Thorsten Aug 4 '12 at 6:21
add comment

A non-automatic way would be to define:

\newcommand{\bcaption}[2]{\caption{\textbf{#1} #2}}

and using the 'bf' option to the package caption.

Here a working example:

\documentclass{article}
\usepackage[bf]{caption}
\newcommand{\bcaption}[2]{\caption{\textbf{#1} #2}}
\begin{document}
\begin{figure}[t]
\centering
 \bcaption{First sentence.}{Second sentence.}
\end{figure}
\end{document}
share|improve this answer
2  
Nice advantage: You can use this to have the bold first sentence as the short LoF/LoT entry. Just use \newcommand{\bcaption}[2]{\caption[#1]{\textbf{#1} #2}} –  NauC Oct 17 '13 at 15:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.