Archive for the ‘LaTeX’ tag
Number Exercises Separately in LyX
Say you’ve got a document with a bunch of exercises and few lemmas. You may want the exercises numbered separately from the numbering of the lemmas and theorem, unlike LyX’s default behavior. This can be achieved by redefining xca, the environment LyX uses for exercises. Add the following to your LaTeX preamble:
\let\xca\@undefined \theoremstyle{plain} \newtheorem{xca}{\protect\exercisename}
LyX will still display the incorrect numbering, but the output will be correct nonetheless. The first line, undefines the LyX’s definition of xca, then we set the style to match the old one and we redefine xca, this time without a reference to the theorems’ counter.
Expectation Symbol in LaTeX
After looking for a builtin expectation symbol in LaTeX, and coming up with none, I’ve defined one. Just add:
% Expectation symbol \DeclareMathOperator*{\E}{\mathbb{E}}
to your LaTeX preamble and you’re done. You’ll also need to add \usepackage{amsmath} or in LyX to tick “Use AMS math package” under Document->Settings->Math Options.
Using the starred version of \DeclareMathOperator makes sure subscripts goes beneath the symbol in display mode.
LaTeX for TiddlyWiki – A MathJax Plugin
Some time ago I came across MathJax, a nifty, Javascript based engine for displaying TeX and LaTeX equations. It works by “translating” the equation to MathML or HTML+CSS, so it works on all modern browsers. The result isn’t a raster image, like in most LaTeX solutions (e.g. MediaWiki), so it’s scales with the text around it. Furthermore, it’s quite easy to integrate as it doesn’t require any real installation, and you could always use MathJax’s own CDN, which makes things even simpler.
Read the rest of this entry »\lyxframeend Undefined when Using Beamer with Lyx
I’m using LyX for the first time with Beamer. Making the title page was smooth. But when I’ve tried adding a new frame (using BeginFrame) I was confronted with the following error
\lyxframeend
{}\lyxframe{Outline}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.After comparing my document to example (working) beamer documents I’ve found out that you must have an EndFrame command after your last frame.Too bad it wasn’t documented anywhere I’ve found as this little thing drove me crazy.
Emulating Kav-Mafrid (em-dash) for the David Font
The David font that is used in Culmus-LaTeX lacks support of Kav-Mafrid, the ligature that is created by two consecutive dashes, --. Because the regular Hebrew dash, Maqaf, is position near the top of the line, one can’t use it instead of the Kav-Mafrid and expect a graphically pleasant result (while Kav-Mafrid can replace Maqaf and the text would still look ok). To make things even more problematic, this ligature is supported by Culmus-LaTeX’s default font, Frank Ruehl, which means one can’t easily switch fonts without hurting the layout.
Read the rest of this entry »
Getting Hyperref to Work with Hebrew (in XeTeX)
The hyperref package is notoriously known to cause problem with RTL text, which unfortunately include Hebrew. In this post I present some preliminary workarounds that enable the user to use the hyperref package with Hebrew and possibly other RTL languages. The solution requires XeTeX which is available in TeXLive. I had no success, yet, to port the workaround to pdfTeX, which is more popular.
Read the rest of this entry »
Algorithm Float Label for Hebrew Document
For a while now I’ve refrained from using the very nice Algorithm environment for LaTeX papers I wrote in Hebrew due to the way it’s label was displayed. The English label was displayed in reverse.
Drawing Finite Automata and State Machines
I had to draw couple of Finite Automata and Turing Machines for some university assignments. Usually I would have done it using Inkscape (as it is my favorite tool for creating figures for my LaTeX documents), but doing it manually is pretty tedious work. Inkscape diagram tool is currently sub par, so everything have to be done by hand. It’s OK if you need to draw one State Machine once in a while, but not suitable for larger quantities. I’ve also tried using Dia, but it also required lots of manual tweaking and tuning.
To my surprise, Graphviz (and especially the dot utility) turned out to be the (almost) perfect tool for the job. It lets you describe the graph in a simple text-based way, and it handles the graph layout by himself. This is somewhat like LaTeX but for graphs (you concentrate on content not layout).
My Finite Automata needed no manual tweaking and resulted in a very nice graphs. For more complicated State Machines it’s sometimes necessary to do some manual tuning. The commands I found most useful to tweak the graph were:
- Grouping nodes to be in the same level –
{ rank="same"; "q1"; "q2"; "q3"}. The other options forrankcan affect how the group is positioned relative to the other nodes in the graph (source, above all,sinkbellow all). - Adding weight to edges –
q1 -> q2 [weight="10"]. This affects the cost of strecting the edge. The higher the weight the straighter the edges will be. - Adding invisible edges –
q1 -> q3 [style="invis"]. This allowed me to control the order of the nodes in the same rank (height).
Last but not least Graphivz can generate the graphs in variety for formats including eps, pdf and svg (which allows post-processing with inkscape).
LaTeX Error: Command \textquotedbl unavailable in encoding HE8
I was testing today the SVN version of LyX 1.6.0 and 1.5.7. Due to a change in the way the double quotation mark (“) is handled, adding it to Hebrew text resulted in the following LaTeX error:
LaTeX Error: Command \textquotedbl unavailable in encoding HE8
Equality-at and Relation-at LaTeX Macros.
These are two useful LaTeX macros for creating equality-at and (the more general) relation-at signs. These macros depend on the mathtools package. As with all other macros you should add them to you preamble in order to use.
The general macro is the \relat. It takes two arguments, the relation and an expression where the relation takes place (the “at”). The equality-at macro, \eqat is a specific case of \relat. I’ve created it because it is commonly used and only requires passing the “at” argument.
Read the rest of this entry »


