About
Shop
LaTeX
Software
Books
Gallery
News
Contact
Blog
Settings
Account
Latest news 2024-10-15: New blog post: Tales for Our Times Book Launch.
Up: TeX/LaTeX  Next: Computing the Parameters for parshape  


Adding Commands to the Preamble

The export to single-paged document functions create a complete LaTeX document, including the document class and preamble. The generated .tex file has the form:

\documentclass[<cls size opt>]{<class-name>}

\usepackage{ifpdf}

<Default Preamble>

\usepackage{pgf}
\usepgflibrary{decorations.text}

<Early-Preamble>

<Definition of \jdroutline>

\usepackage[<options>]{geometry}

<Mid-Preamble>

\pagestyle{empty}

<Definition of \jdrimagebox>

<Late-Preamble>

\begin{document}\noindent
\jdrimagebox{<image code>}
\end{document}

The document class <class-name> and base font size <cls size opt> are obtained from the Document Settings tab of the TeX/LaTeX Settings dialog.

As shown above, the pgf, geometry and ifpdf packages are automatically added to the preamble, and the pgf decorations.text library is also loaded, in case the image contains any text-paths. FlowframTk also defines a command called \jdroutline that's used for any outline text areas (but not text-paths, as outline text-paths are not supported by the LaTeX-related export functions.) The other command automatically defined in the preamble is \jdrimagebox, which is used in case the image turns out to be slightly larger than calculated. (This could be caused by rounding errors, or the difference in fonts, as discussed in Anchor.) The pgfpicture environment is placed inside the argument of \jdrimagebox to prevent spurious blank pages occurring.

In addition \pdfinfo is added with the creation date and optionally a title if the Add \pdfinfo to exported LaTeX documents option is selected in the TeX/LaTeX Settings dialog. (The title is obtained from the image description, see Image Description.) The relevant code is placed after the early-preamble code and before the definition of \jdroutline. The conditional \ifpdf is used so that \pdfinfo is only used with PDFLaTeX.

The <Default Preamble> code is set using the Default Preamble tab of the TeX/LaTeX Settings dialog box. This is general code that applies to all images that are exported to a LaTeX document.

The <Early-Preamble>, <Mid-Preamble> and <Late-Preamble> code are assigned to a specific image, and can be used to add any additional preamble code required for that image. For example, if any of the text areas have alternative text that contains a command that isn't part of the LaTeX kernel, the early-preamble can include the code to load the package that defines the command or the mid- or late-preamble can include the command definition. If the mappings are switched on, any required packages for mapped symbols will automatically be added to the early preamble.

The early-, mid- and late-preamble code can be edited in the preamble panel attached to the side of the canvas (see Figure 10.1). There is a divider between these two areas that can be moved to adjust the visible size of each area, allowing one area to take up more or less room than the other. You can also use the TeX/LaTeX->Preamble Editor menu item to open the preamble panel to its preferred width.

annotePreamble
Figure 10.1: The Preamble Panel

For some look and feels, the divider has small icons that you can click on to move the divider part way across the child window or click again to move it all the way across so that one of the panels is no longer visible. However, for some look and feels, it's not possible to completely hide the preamble panel.

The preamble panel has three tabbed panes, for the early-, mid- and late-preamble code. Each pane has the same layout with a horizontal toolbar and an editor area below it in which you can type the code. The buttons on the toolbar have the following functions:

undoup.pngredoup.png Undo and redo edits. Each pane has its own independent undo/redo manager.

cutTextup.pngcopyTextup.pngpasteTextup.png Cut or copy text from the editor area to the clipboard and paste text from the clipboard to the editor area.

findup.pngfindAgainup.pngreplaceup.png Find, find again and replace. The find button opens the search dialog and the replace button opens the search and replace dialog.

helpup.png Open the manual at this section.


You can also open a popup menu by clicking with the context-menu mouse button or using the context-menu key.

The editor area has syntax highlighting. You can change the colours used or switch off the highlighting using the TeX Editor dialog.

The late-preamble tab is shown in Figure 10.2, where a command has been defined:

\newcommand*{\bvec}[1]{\boldsymbol{#1}}
This command has been used in the alternative text for one of the text areas on the canvas. The dialog box showing this alternative text is also visible.

preambleeditor2
Figure 10.2: The Late-Preamble Tab

The image's early-, mid- and late- preamble code is stored in JDR/AJR files, but not for versions less than 1.9, so make sure you use the latest file version when you save your image. (This is done automatically if you use File->Save.) JDR/AJR version 1.8, introduced in FlowframTk version 0.7, only stores the early-preamble code. FlowframTk version 0.8 (JDR/AJR v1.9) introduced mid-preamble and late-preamble panels. The original preamble panel (which was previously just in a dialog window) is now referred to as the "early-preamble".

If you use the export to package or document class functions, the early-preamble code will be inserted before the option declarations, which allows you to add extra options, if required. The mid-preamble code is inserted after the underlying class or package has been loaded, and the end-preamble code is inserted at the end of the file, just before \endinput. Any instances of \usepackage found in the preamble code will be replaced by \RequirePackage during the export. Note that the default preamble isn't used by the export to package or class functions.

See also:



Up: TeX/LaTeX  Next: Computing the Parameters for parshape  

© 2014 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Cookies Site Map FAQs