### Navigation

- index
- modules |
- next |
- previous |
- versuchung 0.1-0 documentation »
- Experiment Parameters »

# TeX Output

When you are writing a paper or some other text, which uses data that is produced by a experiment, it is very useful to have direct access from your TeX sources to your experiment results. This is especially useful if you want to reproduce your paper with a different version of your programs.

class `versuchung.tex.``DatarefDict`(filename='data.tex', key='')

  Can be used as: input parameter and output parameter

  DatarefDict is like `PgfKeyDict`, but generates keys for dataref.

class `versuchung.tex.``Macros`(filename='data.tex')

  Can be used as: input parameter and output parameter

  A Macros file is a normal `File` with the extension, that you can define TeX macros easily. This is especially useful for writing texts. You may have a experiment, which may be an analysis to an experiment that produces raw data. The produced numbers should appear in your LaTeX document. So instead of copying the numbers you can define TeX macros and use them in the text. This is especially useful if you work on the experiment and the text in parallel and the numbers change often.

      >>> from versuchung.tex import Macros
      >>> macro = Macros("/tmp/test.tex")
      >>> macro.macro("MyNewTexMacro", 23)
      >>> print macro.value
      \newcommand{\MyNewTexMacro} {23}

  `comment`(comment)

    Add a comment in the macro file

  `macro`(macro, value)

    Define a new tex macro with \newcommand. This will result in:

        \newcommand{%(macro)s} { %(value)s}

  `newline`()

    Append an newline to the texfile

class `versuchung.tex.``PgfKeyDict`(filename='data.tex', pgfkey='/versuchung', setmacro='pgfkeyssetvalue')

  Can be used as: input parameter and output parameter

  PgfKeyDict is very similar to `Macros`, but instead of \newcommand directives it uses pgfkeys, can be used as a `dict` and it is possible to read it in again to produce the (almost) same dict again.

      >>> from versuchung.tex import PgfKeyDict
      >>> pgf = PgfKeyDict("/tmp/test.tex")
      >>> pgf["abcd"] = 23
      >>> pgf.flush()  # flush method of File
      >>> print open("/tmp/test.tex").read()
      \pgfkeyssetvalue{/versuchung/abcd}{23}

  In the TeX source you can do something like:

      \usepackage{tikz}
      \pgfkeys{/pgf/number format/.cd,fixed,precision=1}
      [...]
      \newcommand{\versuchung}[1]{\pgfkeysvalueof{/versuchung/#1}}
      \versuchung{abcd}

  Note

  It is better to use `PgfKeyDict` instead of `Macros`, because you can also use spaces and other weird characters in pgfkeys, which cannot be used in TeX macro names.

### Navigation

- index
- modules |
- next |
- previous |
- versuchung 0.1-0 documentation »
- Experiment Parameters »