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.

I am entering the following code in more than 180 times after each \subsubsection.

Is there any way to automate \caption{subsubsection title}?

I tried with \caption{\subsubsectiontitlename} but it does not work.

%%%%%%%%

\begin{figure}[H]
\caption{títol \subsubsection}
\subfloat[Mostres absolutes]{
\includegraphics[width=0.50\linewidth]{Columna_34_absol.jpg}}
\subfloat[Mostres ponderades]{
\includegraphics[width=0.50\linewidth]{Columna_34_pond.jpg}}
\\
\subfloat[]{
\includegraphics[scale=0.1]{Formatge_34_preg.jpg}}
\subfloat[]{\includegraphics[width=0.33\linewidth]{Formatge_34_absol.jpg}}
\hfil
\subfloat[]{\includegraphics[width=0.33\linewidth]{Formatge_34_pond.jpg}}\hfil
}
\end{figure}

%%%%%%%%%%%%%%%%
share|improve this question
add comment

2 Answers

Use a personal environment:

\newenvironment{subsectionfigure}[1]
  {\subsection{#1}\begin{figure}[H]\caption{#1}}
  {\end{figure}}

and then

\begin{subsectionfigure}{Title of this subsection}
\subfloat[Mostres absolutes]{
\includegraphics[width=0.50\linewidth]{Columna_34_absol.jpg}}
\subfloat[Mostres ponderades]{
\includegraphics[width=0.50\linewidth]{Columna_34_pond.jpg}}
\\
\subfloat[]{
\includegraphics[scale=0.1]{Formatge_34_preg.jpg}}
\subfloat[]{\includegraphics[width=0.33\linewidth]{Formatge_34_absol.jpg}}
\hfil
\subfloat[]{\includegraphics[width=0.33\linewidth]{Formatge_34_pond.jpg}}\hfil
}
\end{subsectionfigure}

In the argument of the newly defined argument you put the subsection title, which will be repeated in the caption (although it seems a useless repetition).

share|improve this answer
    
Hi egreg, thanks a lot for your help! –  José Monllor Apr 26 '12 at 21:04
    
@egreg I'm having trouble seeing how this automates the process of repeatedly typing the title of the subsubsection. Won't he still have to type the title of the subsubsection for every single figure? –  JohnReed Apr 27 '12 at 4:35
    
@JohnReed I assumed that each subsection has its own title. –  egreg Apr 27 '12 at 8:08
add comment

Here a solution that works by modifying the subsubsection command. Note: this only works properly if the figure is inside of a subsubsection.

Add these lines to your preamble:

\let\oldsubsubsection\subsubsection
\newcommand\ssv{}
\newcommand\tempcommand[1]{%
\renewcommand\ssv{#1}%
\oldsubsubsection{#1}}
\renewcommand\subsubsection\tempcommand

Then, for your captions in your figures you can use \caption{\ssv}. This should output the name of the current subsubsection title in the caption.

share|improve this answer
    
Thanks John Reed,thanks a lot for your help! This code works perfectly. –  José Monllor Apr 26 '12 at 21:04
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.