0

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(-2.76,1.21)rectangle(17.5,1.91)node[midway,black]{TIKZ_MODULE};
\draw(-2.76,0.51)rectangle(17.5,1.21)node[midway,black]{TIKZ_SUBMODULE};
\draw(-2.76,-0.19)rectangle(4,0.51)node[midway,left]{Name:\hspace*{2cm}};
\draw(4.0,-0.19)rectangle(9,0.51)node[midway,left,black]{Matr.-Nr.:};
\draw(9.0,-0.19)rectangle(13,0.51)node[midway,left,black]{Blatt:\thepage / \pageref{LastPage} };
\draw(13.0,-0.19)rectangle(17.5,0.51)node[midway,black]{TIKZ_SHORT_NAME};
\end{tikzpicture}

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

1 Answer 1

0

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"
                   "TIKZ_SUBMODULE"
                   "TIKZ_SHORT_NAME"))))
  (format "\\begin{tikzpicture}[remember picture,overlay]
\\tikzset{every node}=[font=\\sffamily\\upshape]
\\draw(-2.76,1.21)rectangle(17.5,1.91)node[midway,black]{%s};
\\draw(-2.76,0.51)rectangle(17.5,1.21)node[midway,black]{%s};
\\draw(-2.76,-0.19)rectangle(4,0.51)node[midway,left]{Name:\\hspace*{2cm}};
\\draw(4.0,-0.19)rectangle(9,0.51)node[midway,left,black]{Matr.-Nr.:};
\\draw(9.0,-0.19)rectangle(13,0.51)node[midway,left,black]{Blatt:\\thepage / \\pageref{LastPage} };
\\draw(13.0,-0.19)rectangle(17.5,0.51)node[midway,black]{%s};
\\end{tikzpicture}"
      (cadr (assoc "TIKZ_MODULE" kws))
      (cadr (assoc "TIKZ_SUBMODULE" kws))
      (cadr (assoc "TIKZ_SHORT_NAME" kws))))
#+END_SRC

Your Answer

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

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