Latex

Overview


The latex app provides a way to create latex documents that can be integrated with data in and scripts in your workspace. This makes it easy to automate documentation. For information on latex and automating latex on davinci, please see: latex

Translation


The latex app comforms to the davinci dynamic text specification. That means that you can enter expressions such as


{= 2+2 =}
					


and have it rendered as 4. When you enter a dynamic text expression into the latex app, it will display as you have entered it. If you wish to see how the text would translate when rendered into a pdf document, you can click the translate button, will will evaluation all dynamic text expressions and replace them with their values in the latex text area.

Rendering


After you have created a latex file, you have two options in terms of rendering the document as a text document. The first option is to click the render button, which will render the file within the browser. The rendering engine uses open source code, latejs, created by michael brade and subject to the MIT license. Not all latex packages are supported by in broswer rendering. If you would like save the in browser rendering as a blog, you can click the doc link (upper left corner), which will place a copy of the in browser rendered document component into your clipboard. From there, you can paste it into a blog just like any other component.

The second option is to export the file to your local hard drive and then using any one of several open source latex programs that will render the file as a pdf file.

Automatically Generating a Table


The above table works to display a table, but it has the downside that one has to type in the data. Because the latex app utilizes the dynamic text specification, you can write a script that will iterate over a dataset and insert the appropriate text. The following demonstrates an example, where the dataset is named "category" and contians three columns: category, subcategory and value.

tikz


\begin{table}[h!]
\centering
\begin{tabular}{l l l}
\hline\hline
 category &  subcategory &  value\\\hline
{: 
  $val("category").forEach(p=>{
    print(p.category);
    print(" & ");
    print(p.subcategory);
    print(" & ");
    print(p.value);
    print(" \\\\ \n");
  });
:}\hline

\end{tabular}
\end{table}

					


As a shortcut to writing the above code, the latex app includes the ability to auto generate a table from a dataset. Open the table tool by clicking the table link. There will be drop down box. Select the dataset that you wish to generate a table from, and then click add. The table script will be inserted in the latex document where the current mouse cursor is at. Note, this will generate a table for all columns, if you wish to only use a subset of the columns, or use them in a particular order, you will need to edit the script.

Automatically Generating a Chart


In order to use the pgf plot facilities, you must include the following at the top of your document, after the document class declaration.


\usepackage{tikz}
\usepackage{pgfplots}

					


For the pie chart, the following needs to be added after the document class declaration.


\usepackage{tikz}
\usepackage{pgf-pie}

					


Templates


The template funcitonality is designed so that you can save bits of latex text that can be inserted into your latex document simply by clicking a button.

To add a new template, open the template section by clicking the templates link. Then, in the provided textbox, enter some latex text and click the add button. This will create a new button with the latex displayed within the template section. As an example, try entering the following


\sum_i^n
					


This will add a sum button in your template area. Whenever you click this button, the given text will be entered inot the latex document that is currently selected.

To remove a template, select the remove checkbox, and then click the desired template button.

Tempates are temporary, that is, when you start the latex app again, all defined templates will be gone. This is largely due to the fact that the templates required for any given document are typically different than any other document. However, if you wish to save your templates, click the save button. This will save your templates to your local hard drive (in your browsers local data cache) and they should be available the next time you open the latex app. However, because these are save on your local machine, they will not be available if you log onto davinci from a different machine.

Gallery


The normals chart displays two normal distributions with different standard deviations. A slider control adjusts the expected value of one of the normals.

Contents