I am trying to have some environments in my LaTeX document where the font in general is smaller than in the main text. This means that whenever I include a figure, the caption from the \begin{figure}... should have the same (smaller) font size. I found answers where the change is globally by providing the font size parameter to the caption package. Yet I was wondering if I could do this locally for some figures. Actually, I would like to know if this is possible in the definition of the exercise environment I have:

\usepackage[lastexercise]{exercise} % for exercise environment

% set font for exercise environment

% change format of exercise environment
                \ExerciseName\ \ExerciseHeaderNB. \ExerciseHeaderTitle

% change font for answers header
                Solution:\ }}

Can I somehow change the font size for the figures in such environment?


You can define an \ExerciseCaption to use within the exercise. By using \captionsetup in caption.sty the caption can be changed locally.


  \caption{Test 1}

  \ExerciseCaption{Test 2}

Figure \ref{TA} and Figure \ref{TB}

enter image description here

| improve this answer | |
  • Thanks for replying. I'm getting a Missing \endcsname inserted. error. Do you know why? – aaragon Jul 14 '16 at 12:45
  • I cannot get the same error here. I have tried to include also the exercisepackage together with your settings, and a figure within an exercise. But it compiles as expected. Maybe you have some other included packages? – StefanH Jul 14 '16 at 13:20
  • I have a lot of included packages. I'm using the subcaption package actually. Any ideas on how I can determine the source of the conflict? – aaragon Jul 14 '16 at 13:21
  • I think subcaptionis part of caption so that should work. I would start with your original (compilable) document and just add \usepackage{caption}. If that works add \captionsetup{font=footnotesize} just before a caption. If that works it is only the command left. – StefanH Jul 14 '16 at 13:31
  • 1
    The footnotesizeis an input parameter to caption, telling it to use \footnotesize. How that is internally handled is something else, and you can only give the per-specified inputs. – StefanH Jul 14 '16 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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