I would like to use orgmode for preparing exam questions. For tex-template I am using tikz which includes some text entries e.g. for the title and subtitle.

The tex part for tikz looks e.g. like:

\begin{tikzpicture}[remember picture,overlay]
\tikzset{every node}=[font=\sffamily\upshape]
\draw(9.0,-0.19)rectangle(13,0.51)node[midway,left,black]{Blatt:\thepage / \pageref{LastPage} };

The string TIKZ_MODULE, TIKZ_SUBMODULE and TIKZ_SHORT_NAME should be replaced by the corresponding orgmode entries, see below:

#+TITLE: title
#+SUBTITLE: subtitle
#+AUTHOR:  author
#+DATE: Sept 2021
#+INSTITUTE: department
#+TIKZ_MODULE: module
#+TIKZ_SUBMODULE: submodule
#+TIKZ_SHORT_NAME: short_name

Do you have a hint how this can be done?

It is also possible that the I use the TITLE and SUBTITLE for the TIKZ_MODULE and TIKZ_SUBMODULE, but I am not sure, if this is easier.

Actually I am sure, that this is already described somewhere, but I do not know which words describe my question for searching.


1 Answer 1


It might be easier to use a library of babel like approach. Here I setup a src block named tikz in a section that is not exported. You could put this in another file, and load it via library of babel (see org-babel-lob-ingest.

Then this line #+call: tikz[:eval t]() inserts that text at export time, or you can execute it and see it when writing the document.

#+TIKZ_MODULE: module
#+TIKZ_SUBMODULE: submodule
#+TIKZ_SHORT_NAME: short_name

#+call: tikz[:eval t]()

* lob                                                              :noexport:

#+name: tikz
#+BEGIN_SRC emacs-lisp :results latex
(let ((kws (org-collect-keywords '("TIKZ_MODULE"
  (format "\\begin{tikzpicture}[remember picture,overlay]
\\tikzset{every node}=[font=\\sffamily\\upshape]
\\draw(9.0,-0.19)rectangle(13,0.51)node[midway,left,black]{Blatt:\\thepage / \\pageref{LastPage} };
      (cadr (assoc "TIKZ_MODULE" kws))
      (cadr (assoc "TIKZ_SUBMODULE" kws))
      (cadr (assoc "TIKZ_SHORT_NAME" kws))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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