How to Add the arg max and arg min Functions to Lyx

The arg max and arg min functions are not standard as math functions in LaTeX. As a result, they are not straightforward to use in Lyx either. However, it is quite simple to do so:

  1. Add the following code to the LaTeX preamble in Lyx (Document > Settings > LaTeX Preamble):

  2. When you create a new math field in Lyx, simply type \argmax or \argmin. You can follow it by an underscore if you need text below the arg max or arg min functions. This text will be centered across all six letters.

It’s that simple!

How to Use a New Latex Class in Lyx

Let’s say we have a custom new Latex class called “newclass.cls” which we want to be able to use with Lyx under Windows.

  1. Copy the new Latex class file “newclass.cls” into the MikTeX directory within your user settings folder like so: C:\Users\UserName\AppData\Roaming\MiKTeX\2.8\tex\latex\newclass\newclass.cls. Remember to replace UserName with your own Windows user name.
  2. Update the MikTeX list of classes by clicking the Windows Start button and typing cmd into the search box. When the black command line window displays, type texhash and hit Enter.
  3. Next we need to create a layout file for Lyx to work with. This file contains instructions on how to roughly format a document when displayed within the Lyx program itself. More importantly, the layout file points to the Latex class for generating the final output. It is helpful to start by just modifying an existing layout file which is similar in purpose to the Latex class we are trying to add. For example, if our new Latex class is a template for an article, we might want to start by copying article.layout from C:\Program Files (x86)\LyX20\Resources\layouts and pasting it into C:\Users\UserName\AppData\Roaming\LyX2.0\layouts. Rename the file to match your class name, say, “newclass.layout”
  4. Open up your new layout file, and look at the second line. Replace it with:
    # \DeclareLaTeXClass[newclass]{Title of Class}
    Enter your class name within the [] brackets, and enter whatever descriptive name you want to call the class within the {} braces.
  5. Open Lyx, and click Tools > Reconfigure. Restart the Lyx program when it prompts you to do so.

That’s it! When you start a new document in Lyx, your new class should appear within the drop-down box for Document Class in the Document Settings window (Document > Settings).

Tested with Lyx 2.0 and MikTeX 2.8 under Windows 7.

How to Copy an Equation from MathType to Lyx

Recently, I’ve been using Latex with Lyx instead of Microsoft Word to format my dissertation and research papers. I find managing the formatting to be much easier, and the layout is guaranteed to be consistent throughout the document. However, much of what I have done previously was in Word, and I often want to transfer math equations I wrote previously in MathType over to Lyx rather than rewriting them from scratch.

While the method is somewhat of a nuisance because of the terrible way MathType handles Latex, it is certainly possible, and can often be faster than rewriting an equation.

  1. In Microsoft Word, select the MathType equation you want to copy over to Lyx.
  2. Click the MathType tab at the top of Word. Click Toggle Tex. This will convert the MathType equation image into Latex code.
  3. Copy the Latex code. In my example, I get:
  4. Insert a new math formula field in Lyx. Here is the tricky part. You cannot simply paste the Latex code you have copied directly into this formula field. Otherwise, it will show up as text, not a formatted equation, like so:
  5. MathType adds the \[ characters to the beginning and the \] characters to the end of the Latex code. DELETE these characters before pasting into Lyx. (For multi-line equations, MathType also may surround the Latex code with \begin{align} and \end{align}. These must be deleted too to paste into Lyx properly). In my example, I end up with:
  6. With the extra two characters removed from the beginning and end of the Latex code, the code will paste properly into Lyx:
  7. However, as you can see in the example, MathType inserts extra braces into the Latex code, more than are necessary. These must be removed manually, but at least the majority of the equation formatting is preserved and recognized by Lyx’s formula editor. Once removed, you are done!

This method was tested using MathType 6.5 and Lyx 1.6.8