Sunday, September 11, 2011

Stacking things in LaTeX/LyX

Sometimes you need to put one thing on top of another. A good example is when the indices over which to sum are a complicated intersection of sets. In order to have them appear nicely below the summation consider using \substack as opposed to \atop. The Internet is rife with documentation for these commands. I will just mention the use of \substack in LyX:

In a math mode box you can type \substack. This will turn into the substack mode box. Here you can type your first line. To get the next line just hit Ctrl+Return. This will send you into the next line where you can type your line. I guess you can continue in this fashion to some point limited by some cryptic limit that has been hard-coded into the innards of LyX. ;p

Tuesday, September 6, 2011

LyX: Wierd behavior with \setcounter{}{}

Sometimes I want to change the number used for an enumerated list item. For example, if an item is supposed to labeled 2, and I want it to instead read 3 (thus effectively skipping 2), then I would add an ERT box after the enumerated item's number, but before the item. Inside the ERT box, in this example, goes

[3.]\setcounter{enumi}{3}

Usually this works. But sometimes this does not work and instead the usual number, in this case, 2 is displayed and then [3.] is displayed following the 2.

After comparing working and non-working instances, I was able to determine that the non-working instances had the \noindent LaTeX code. The following are examples of working and non-working instances.

Works:
-----------
\begin_layout Enumerate
\begin_inset ERT

status open

\begin_layout Plain Layout
[3]
\backslash
setcounter{enumi}{3}
\end_layout

\end_inset
-----------


Doesn't work:
-----------
\begin_layout Enumerate
\noindent
\begin_inset ERT

status open

\begin_layout Plain Layout
[3]
\backslash
setcounter{enumi}{3}
\end_layout


\end_inset
-----------

Plus, if you get it working without the \noindent, if you try to shrink the font down to tiny, the same behavior results even without any \noindent to be found in the LyX code.

For example, if you see that the ERT box has shruken along with the surrounding text (blue highlighting only for emphasis):

then your pdf will look like this:

Note the annoying [3.] that shows up here. While if you reset the font size of the ERT box (including that right up next to the first shrunken text), like so
your pdf will look correct, like this:

This post provides a workaround, but does not provide a full understanding of the underlying issue. :(

Don't ask me why, but yes, I have multiple 3s in a row.

Sunday, September 4, 2011

Changing property of multiple objects in xfig

Sometimes one wants to give a group of objects in an xfig figure the same property. For instance, I want to make each object in my current selection have a common depth. Does anyone know how to accomplish this?

Graphics xfig can edit

It is often necessary in teaching and writing to modify a plot of data or a graph of a function using xfig. For instance, I create eps figures from Matlab or wxMaxima, and I need to edit out unnecessary tick marks or tick mark labels. xfig can operate on *.fig files. So, you need to convert the eps file to a fig file. This blog post is just a shout-out to Linux for Research's short post about it. Find it here. Thanks, Linux for Research!

Thursday, September 1, 2011

Forcing LyX to open newer file formats

Sometimes you create LyX files on the newer version, say, on your office machine, and try to open them on an older version, say, at your home machine. In order to put off upgrading my whole system (long story), I can simply rewrite the header information on the file.

Make a backup of the old file.
Identify the first two lines, which should look like:

#LyX 2.0 created this file. For more info see http://www.lyx.org/
\lyxformat 413


Comment out those lines and add the following two lines above the now-commented-out lines

LyX 1.6.7 created this file. For more info see http://www.lyx.org/
\lyxformat 345


So that it reads

LyX 1.6.7 created this file. For more info see http://www.lyx.org/
\lyxformat 345

##LyX 2.0 created this file. For more info see http://www.lyx.org/
#\lyxformat 413


Note that when you open your new file you may receive error messages from LyX. You can ignore them at your own risk. If I see something serious I look more closely, but at the very least I can at least copy and paste my content into a new clean file from the older LyX.

Lastly, consider destroying the backup of the LyX file.