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 would like to have a section title of special type: I need it to be a letter with a figure in superscript. My code (that does not work) would be:

\documentclass[12pt,a4paper]{article} 
\usepackage[slovak]{babel} 
\usepackage[utf8x]{inputenc} 
\usepackage[T1]{fontenc} 
\usepackage{palatino,verbatim}
\usepackage{amsmath} 
\usepackage{graphicx} 
\usepackage{float}

\begin{document}
\section{$\Sigma_1^{\includegraphics[scale=0.15]{example-image-a}}$}
\end{document}

Is it possible to do this?

share|improve this question
    
Great, thank you. –  Suzie Apr 25 at 16:02
    
otherwise the standard trick of using \section[stuff for the toc, no unprotected fragiles]{actual section heading} will work.... –  cmhughes Apr 25 at 16:08
    
@cmhughes Can you, please, give some simple example of what you suggested? Thanks. –  Suzie Apr 25 at 16:14
    

1 Answer 1

up vote 4 down vote accepted

You can either \protect the command from expanding via

\protect\includegraphics[..]{...}

or make it robust using something like etoolbox:

enter image description here

\documentclass{article}
\usepackage{graphicx,etoolbox}
\robustify{\includegraphics}
\begin{document}
\section{$\Sigma_1^{\includegraphics[scale=0.05]{example-image-a}}$}
\end{document}
share|improve this answer
    
Thank you, both work very well. Can you, please, explain, what does the \protect command do? –  Suzie Apr 25 at 16:09
1  
@Suzie: You should read What is the difference between Fragile and Robust commands? Specific to your case, the argument of \section is considered to be a "moving argument" as it not only winds up in the text where you place it, but also possibly in the ToC. As such, it is written to file where full expansion is attempted unless you \protect (or \robustify) it. Also see David's comment on this topic. –  Werner Apr 25 at 16:36

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.