I want my frame title to look something like this:

Exercise 1 a)

I know I could achieve this by doing the following:

\begin{frame}{Exercise 1\hfill a)}


But I do not want to write \hfill all the time. Also, I can't use the subtitle for the a) as I want to use the subtitle for other stuff.

I thought something like this must be possible:

\begin{frame}{Exercise 1}

But I cannot use \insertframetitle there, and I don't know why.

Does anybody have an idea how to achieve what I want?

  • Welcome to TeX.SX! It will be easier for others to help you if you add a minimal working example, that is, a minimal yet compilable code that shows the problem. For example, in this case to propose a useful solution it might be important to know what beamer style you are using.
    – Vincent
    Jan 18 at 17:09
  • 1
    Why not \newcommand\exnum[1]{\frametitle{Exercise\hfill{#1}}}?
    – Werner
    Jan 18 at 17:38
  • @Werner 'cause I want to hard-code the word exercise. I might give different frames different titles.
    – Luke
    Jan 18 at 19:19
  • @Luke: Then you could use a macro for that: \newcommand{\frametype}{Exercise} and use \newcommand{\exnum}[1]{\frametitle{\frametype\hfill #1}}... and then change \renewcommand{\frametype}{Example}, say.
    – Werner
    Jan 18 at 20:21

1 Answer 1


Similar approach as @Werner's comment, but instead of hardcoding anything, you could create a macro with two arguments:



  • That's a great idea. I was kinda stuck thinking that I have to set the title when starting the frame env. I somehow forgot that It's just fine to do it inside the frame env.
    – Luke
    Jan 19 at 6:26
  • @Luke Personally I actually prefer to set the title inside the frame. The \frametitle macros is much more powerful and robust than the hacky \begin{frame}{title} syntax. Jan 19 at 9:38
  • Why is \begin{frame}{title} hacky? I did not know this?
    – Luke
    Jan 20 at 9:09
  • @Luke The code inside beamer to get this working is quite hacky. Life would be so much easier without this syntax :) Jan 20 at 9:10
  • ah thanks for explaining. The I'll probably stop using this syntax :)
    – Luke
    Jan 20 at 9:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .