-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LaTex/Beamer add hook before \begin{frame}... and after \end{frame} #4403
Comments
Do you really need to enclose the complete frame in the exercise mode, i.e. do you need If it would suffice to wrap just the content of your frame into the exercise mode, you could use a simple lua-filter like local exercise = false
function Header(h)
local exercisemode = pandoc.Null()
-- handle end of previous excercise mode
if exercise then
exercise = false
exercisemode = pandoc.RawBlock("latex", "\\exercisemodefalse")
end
-- handle current header: start exercise if attribut `hook` is set to `exercisemode`
if h.attributes["hook"] == "exercisemode" then
exercise = true
return { exercisemode, h, pandoc.RawBlock("latex", "\\exercisemodetrue") }
end
-- else return header
return { exercisemode, h }
end This filter would produce the following TeX from your example (using \begin{frame}{%
\protect\hypertarget{exercise-a-new-quiz}{%
Exercise: a new quiz}}
\exercisemodetrue
Just an example \ldots{}
\exercisemodefalse
\end{frame}
\begin{frame}{%
\protect\hypertarget{no-exercise}{%
No exercise}}
Nothing else
\end{frame} |
then you could also you write the raw TeX (i.e. |
If you write raw TeX like @mb21 suggested, this raw TeX would be part of the frame before. Because every Header of a certain level is acting greedy until the next Header of the same or higher level. So the raw TeX-Block in the AST would be part of the last Header, which means that it will be written inside of the frame before the current frame. And that is not a solution, because you need it between So that is not the right way to fix the problem. (Yes, I do think this is a design problem of the current AST-design! ;-) ) That is also true for (any) filter suggestion, because setting anything inside of a frame won't change the current frame (and also not the next frame!) or anything inside of the frame title environment. If you write So, change the behavior inside of the pandoc latex-writer is, for me, the only possible solution. -- Sorry. Thanks to @mb21 and @cagix, but it your ideas won't work .. :-( |
Currently we reorganize the AST for slides in the writer,
so the filter can't get to the slide structure.
Now that we have native Divs, we could consider reorganizing
things:
- the beamer, reveal.js, etc. writers would expect things to
be already organized into a serious of Divs with class
"slide", corresponding to the slides.
- we'd have a built-in filter that creates this Div
structure from the regular AST in the same way as
currently
- the writer would check to see if the AST includes the
Div structure for slides, and call this filter if not
- but the filter could also be called manually from e.g.
a lua filter; this would allow people to do fine-grained
adjustments on slide structure from within a lua filter.
- writers could also just include the Div structure for
slides manually.
It's a bit complex but worth considering.
|
I'm not sure about if this would make it easier. Complex, may be to complicated, if you would ask me. something like
will first be converted to something like
so that it will be possible to add something in between like
or do I misunderstood something? |
Yes, you understand the idea.
|
Okay, that would be perfect. - When it will arrive in the releases? ;-) --- Yes, i'm pushing, 'cause I need it badly! :-) |
Sorry, is there anything I could test or use in this direction? -- Maybe in a branch? ;-) Yours |
Sorry...I have limited time to work on pandoc; you shouldn't expect any
changes soon.
|
I think it would be a great idea to add the possibility to call a hook macro in latex/beamer right before and after the creation of a frame.
This would make it possible to translate something like
to an latex output with might change the behavior frame title styling etc:
I need something like this desperately to change the frame title style of a slide when it shows exercises..
Thanks
Norman
The text was updated successfully, but these errors were encountered: