TransWikia.com

How can I create a command inside a slide in beamer such that it creates another slide after the current one?

TeX - LaTeX Asked by Italo Marinho on April 20, 2021

So, let me show you a MWE of my problem.

documentclass[serif, aspectratio=169,t]{beamer}
usepackage[brazil]{babel}
usepackage[no-math]{fontspec}
usepackage{euler}
setmainfont{Calibri}
usepackage{lipsum}
newcommand{rascunhoem}[1]{{usebackgroundtemplate{includegraphics[width=paperwidth, height = paperheight]{imagens/image.pdf}}begin{frame}{#1}end{frame}}}
newcommand{questao}[1]{{usebackgroundtemplate{includegraphics[width=paperwidth, height = paperheight]{imagens/image.pdf}}begin{frame}[allowframebreaks]#1end{frame}}rascunhoem{Rascunho}rascunhoem{Rascunho}}

begin{document}

questao{lipsum[1-2]gab{Teste}lipsum[3-5]}

end{document}

If you want to test it, I’ll send a template image in PDF for you to compile, on the link below:

Link for an example of image.pdf, for the slide’s background

So, now here’s what I’ve been trying to do without much success.
As you can see, there’s a gab{} command I haven’t defined between the lipsum paragraphs.

I have lots of blocks of slides with this configuration, in which the first paragraph has the gab{} command (for other purposes) and then the rest of the slide after it.

I’d like to make gab{} to add a slide after the two "Rascunho" slides. For example, if I create:

questao{Here's a text example before the command. gab{This'll be added after the two ``Rascunho'' slides} Here's the text after. 
There's no way I can move the command to the end, I have to leave it here, since I have more than ten thousand blocks like this.}

So, I’d like to create a slide after the two "Rascunho" ones with the text This'll be added after the two ``Rascunho'' slides using the gab{} command.

Again, I can’t change the command’s position along the text, and I can’t change the structure I presented. I just want to build the gab{} in such a way it does what I asked.

One Answer

You can define gab to define another macro (here @gab) which is used at the end of your code for questao, e.g.

documentclass[serif, aspectratio=169,t]{beamer}

usepackage[brazil]{babel}

newcommand{rascunhoem}[1]{%
   begingroup
   usebackgroundtemplate{includegraphics[width=paperwidth,height=paperheight]{example-image}}%
   begin{frame}
   #1
   end{frame}
   endgroup
}

makeatletter
newcommand{questao}[1]{%
   begingroup
   def@gab{}%
   defgab##1{@bsphackgdef@gab{##1}@esphack}%
   usebackgroundtemplate{includegraphics[width=paperwidth,height=paperheight]{example-image}}%
   begin{frame}[allowframebreaks]
   #1
   end{frame}
   rascunhoem{Rascunho}%
   rascunhoem{Rascunho}%
   ifx@gab@empty
      defnext{relax}%
   else
      defnext{begin{frame}@gabend{frame}}
   fi
   next
   endgroup
}
makeatother

begin{document}

questao{Here's a text example before the command. gab{This'll be added after
the two ``Rascunho'' slides} Here's the text after. There's no way I can move
the command to the end, I have to leave it here, since I have more than ten
thousand blocks like this.}

end{document}

enter image description here

This does not support multiple occurrences of gab within a call to questao.

Correct answer by campa on April 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP