Archive for the ‘LaTeX’ tag
nameref Doesn’t Work Properly with Theorem Environment
I came across not-so-expected behavior in nameref, the package responsible for creating named references, when used in conjunction with theorem environments such as the one provided by amsthm. For example take a look at the following LaTeX document.
\documentclass{article} \usepackage{amsmath,hyperref} \begin{document} \section{My Section} \newtheorem{theorem}{Theorem} \begin{theorem}[My Theorem] \label{theo:My}0=0 \end{theorem} This is a named reference: \nameref{theo:My} \end{document} |
You would expect the named reference to refer to the theorem’s name. However in reality it refers to the section’s name.
Separate Numbering for Problems in LaTeX
By default when using the amsthm to create environments such as theorems, claims and problems, they all use the same numbering. Sometimes it’s annoying, as the numbering for the problems should generally be unaffected by the theorems present (or lack of them). For example the default behavior produces:
Problem 1 Problem 2 Theorem 3 Problem 4 |
where the desired behavior would be (in my opinion):
Problem 1 Problem 2 Theorem 1 Problem 3 |
Fortunately, this can be done by redefining the problem environment.
\let\problem\@undefined % undefines the existing problem environment \theoremstyle{definition} % set the style of the new environment to 'definition' \newtheorem{problem}{\protect\problemname} % (re)define the 'problem' environment |
The \theoremstyle can be one of three defaults plain, definition and remark or some custom style defined using \newtheoremstyle.
See amsthm‘s documentation for more information, such as subordinately numbering (numbering per section).
Hebrew Support in Hyperref – Situation Review
It’s been a bit more than three years since I’ve written about a workaround for getting hyperref to play (almost) nicely with Hebrew. Over the past few weeks, I saw I rising interest in this and few people contacted me regarding this issue. So I thought it’s a good opportunity to better document the current situation, and possible ways that should be further investigated which I believe might lead to better solutions.
Read the rest of this entry »
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.



