isteinbrecher / latex2ai

LaTeX Plugin for Adobe Illustrator
MIT License
147 stars 5 forks source link
adobe-illustrator latex

LaTeX2AI

LaTeX2AI is a plugin for Adobe Illustrator that enables the use of text labels typeset in LaTeX inside an Illustrator document. Currently LaTeX2AI supports:

Requirements

Currently LaTeX2AI only works on Adobe Illustrator for Microsoft Windows. The following software dependencies are required:

Install LaTeX2AI

Install LaTeX2AI from rebuild binaries can be downloaded from the GitHub release page. They consist of two files LaTeX2AI.aip and LaTeX2AIForms.exe. There are two ways to add LaTeX2AI to Illustrator:

Build LaTeX2AI from source

Requirements

The additional requirements to build LaTeX2AI from source are:

Getting started

  1. Download and unpack the SDK depending on your Illustrator version:
  2. Go to the sample code folder Adobe Illustrator <YOUR VERSION> SDK/sample code and run
    git clone https://github.com/isteinbrecher/latex2ai.git
  3. Go to Adobe Illustrator <YOUR VERSION> SDK/sample code/LaTeX2AI and run
    git submodule update --init
  4. Open Adobe Illustrator <YOUR VERSION> SDK/sample code/latex2ai/LaTeX2AI.sln with Visual Studio, select the build type (Release or Debug) and the target (x64) and compile the solution. It might be necessary to change the Windows SDK version for LaTeX2AI and the .NET Framework version for LaTeX2AIForms to match the ones available on your system.
  5. The compiled binaries are located at Adobe Illustrator <YOUR VERSION> SDK/sample code/output/win/x64/<Debug/Release>. This directory has to be set as the Plugin directory in Illustrator. The relevant files created, i.e. the ones needed to run LaTeX2AI are LaTeX2AI.aip and LaTeX2AIForms.exe. The executable LaTeX2AIForms.exe contains the UI for LaTeX2AI and should only be called from within the plugin itself.

How to use LaTeX2AI

LaTeX2AI uses the Placed Art feature of Illustrator to embed LaTeX labels (compiled to .pdf) inside an Illustrator document.

The plugin adds four buttons to the main toolbar:

Additionally, double clicking on a LaTeX2AI label enabled the editing mode.

Create / Edit a LaTeX2AI label

The following form appears when creating or editing LaTeX2AI labels:

Create / Edit

Placement

This option defines how a label behaves when it its size changes. Take for example the well-known formula $\sum_{k=0}^{\infty}\frac{x^k}{k!}$ which is placed inside a rectangle:

Placement small

The green box indicates the boundary box of the LaTeX2I label and the dot describes the placement of the label, i.e. if the size changes the position of this dot relative to the label will stay the same. If the previous label is now changed to \displaystyle we get the following result:

Placement large

The size of the label changed due to a change in the underlying LaTeX code, but the position (the indicated dot) stayed the same.

Baseline placement

Additionally there is the possibility of a baseline placement. This will result in a label where the baseline is exactly in the vertical center of the label. The resulting label can now be easily adjusted and snapped to align with another baseline label or Illustrator text:

Placement baseline

Stretch behavior

This option controls how a LaTeX2AI text label behaves when the size of the boundary box changes in Illustrator:

The following Figure illustrates the different options:

Stretched labels

Please note that the remain original size option leads to issues if the item is bend (see the red boxes in the previous Figure).

Every time a label changes the boundary box is reset so that it matches the size of the actual places PDF file. With the Redo items button the boundary box of all labels can be redone. It is generally advisable to redo all boundary boxes before exporting the Illustrator document, to ensure that the font size will be correct for each label.

LaTeX header

It is assumed that all Illustrator files in the same directory use the same LaTeX header LaTeX2AI_header.tex (if no one exits in the directory, it will be created the first time it is needed). This header can be edited to include packages and macros needed for the labels (LaTeX2AI supports \input commands in the header, also recursively).

File structure

The .pdf files for the LaTeX labels are stored in the links subfolder of the document directory. It is not required to keep track of the files in the links folder, LaTeX2AI manages and deletes unused label files.

Known issues

Missing image files

When opening a document after it is moved / copied it can happen that Illustrator can not find the .pdf files for the labels. In that case the following warning message appears: Missing labels The missing labels can be ignored by selecting Apply to All and Ignore. After the document is loaded, LaTeX2AI automatically restores the missing items.

Redo not working when changing an item

Redoing an item by double clicking on it will not trigger an individual undo entry. The changes made in the redo process will be appended to the last undo entry.

Non ASCII characters in the document name or path

LaTeX2AI does not work if there are non ASCII characters in the document name or full document path.

License & How to cite

LaTeX2AI is under the MIT license, see ./LICENSE. If you use LaTeX2AI to create figures for your work, please acknowledge it with a link to the GitHub repository. For example:

Work that uses LaTeX2AI

Contributing

If you are interested in contributing to LaTeX2AI, we welcome your collaboration. For general questions, feature request and bug reports please open an issue.

If you contribute actual code, fork the repository and make the changes in a feature branch. Depending on the topic and amount of changes you also might want to open an issue. To merge your changes into the main LaTeX2AI repository, create a pull request to the develop branch (this branch will be merged into main with the next release). A few things to keep in mind:

Changelog