Passing ignorenonframetext
as an option to Beamer, causes it to ignore all the text that is not inside a frame. It is useful when you want to add content for the article version of the presentation (or simply script lines for yourself) that would not show in the regular presentation. LyX puts the title elements outside any frame. Therefore, if you use ignorenonframetext
you end up missing the title frame. The solution is to manually wrap the title block (the title, author, institute, etc.) in a frame and append to it \maketitle
. This will cause the title frame to be rendered correctly.
Category: LaTeX
Optimize LaTeX PDF Output for Kindle
Kindle can display PDFs, but usually the result is very hard to read. Normal PDFs are not suitable, especially when it comes to paper size for the, relatively, small display of the Kindle. For a forthcoming project, which I intend to write in LaTeX and read on Kindle, I looked into optimizing the document settings so the result will be rendered in a readable manner on Kindle.
I’ve started with the normal article class. The result, is not good at all:
While Kindle zooms-in automatically to remove, the usually very wide, margins LaTeX uses, the big (A4) paper size, still results in a tiny font on the Kindle display. Switching to Koma-Script, is a bit better, but mainly provides better mechanisms to control the paper size for later experiments.
The next try, is simply to use the A5 paper size. The result is getting better, but the paper size is still too big. Setting the paper size manually to 12cm by 9cm (the screen’s physical dimensions) and setting the pagestyle
to empty
(removes the page numbering among other things) results in a much better results because of the (still) wide margins and the auto-zoom in a font size that is too big and not enough content fits in a page:
Finally, by manually setting the text area to be a bit smaller (11cm by 8cm) than the paper size, results in small margins and very little auto-zoom. The output can be clearly read on the Kindle, and still quite a bit of text fits on a single page:
The LaTeX code for the last example is:
\documentclass[DIV=calc,paper=9cm:12cm,pagesize]{scrartcl} \areaset{8cm}{11cm} \pagestyle{empty} \usepackage{lipsum} \begin{document} \lipsum \end{document}
KOMA-Script: Specifying Binding Correction for RTL Documents
The KOMA-Script bundle provides an option to specify the amount of binding correction needed in order to compensate for the width lost in the binding process. By default, it is added to the left margin, which is where the binding is applied for Left to Right languages. However, if a document is written in Hebrew or Arabic, one binds it on the right. The KOMA-Script manual does not consider that option. After a bit of playing I’ve found out that simply using a negative value for the binding correction works.
For example, if in an English document you would use
\documentclass[BCOR=8.25mm]{scrreprt}
For Hebrew you would set
\documentclass[BCOR=-8.25mm]{scrreprt}
Creating a Hebrew Document in LyX 2.1 with XeTeX
This post complements the basic LaTeX template I gave yesterday for typesetting Hebrew with XeTeX. I’ll walk through the (short) list of steps needed to configure LyX with XeTeX.
Prerequisites
- LyX 2.1 or later (I’ve also tested with the development version of 2.2). I had very limited success with LyX 2.0, so you should probably avoid it.
- XeTeX – I’ve tested with version
3.1415926-2.4-0.9998
which comes with TeXLive 2012, but I guess any recent version will do. - The
polyglossia
andbidi
packages. Again I’ve used those which come with TeXLive 2012. - Good TrueType Hebrew fonts. I recommend Culmus 0.121 or newer. You may also try and use the fonts that come with your operating system, they might work as well.
Setting up the document
Create a new document and open the settings dialog (Document
-> Settings...
).
- Pick a suitable Document class. I recommend “KOMA-Script Article” but “Article” works just as fine. Avoid “Hebrew Article”, as it is broken under XeTeX.
- Under
Fonts
check the box next to `Use non-TeX fonts (via XeTeX/LuaTeX) and select suitable fonts:- Roman: Frank Ruehl CLM. David CLM is also a good choice with somewhat better italics variant.
- Sans Serif: Simple CLM.
- Typewriter: Miriam Mono CLM.
- There is no need to change the Math font.
- Under
Language
select Hebrew as the document’s language.
That’s basically it. You can now write your document and compile it. I would suggest saving these settings as default (via “Save as Document Defaults”) or saving it as a template so you won’t need to repeat those steps.
Writing in English
To insert English text in your Hebrew document, you need to change the current language. The easiest way to do so is to create a keyboard shortcut for it:
- Go to Tools -> Preferences -> Editing -> Shortcuts
- Write “language” under “Show key-bindings containing:”.
- Select “language” under “Cursor, Mouse and Editing Functions” and click “Modify” to set a keyboard shortcut (
F12
is traditionally used for this).
Now you can toggle the current language between English and Hebrew by simply pressing F12
.
Remark about Fonts
It is preferable to use fonts that provide both Hebrew and Latin scripts, as otherwise there might be significant style differences which make the document look weird. It is possible to set a different font for Hebrew and Latin, but care needs to be taken to match styles. To do so, add the following lines to the Preamble:
\newfontfamily\hebrewfont[Script=Hebrew]{David CLM}
\newfontfamily\hebrewfonttt[Script=Hebrew]{Miriam Mono CLM}
\newfontfamily\hebrewfontsf[Script=Hebrew]{Simple CLM}
Hebrew with XeTeX Example
This is an example of a document in XeTeX (Actually XeLaTeX). I’ve used The fonts from the Culmus Project. Note that you’ll need Culmus 0.121 or newer in order to get the Frank Ruehl font in TrueType. As you can see, Nikud are placed correctly. The cantillation marks (טעמי המקרא) are in a small offset compared to the ideal position.
Overall, XeTeX works much better with Hebrew (and easier to use) than pdfTeX.
\documentclass{minimal}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\usepackage{fontspec}
\setmainfont{Frank Ruehl CLM}
\setmonofont{Miriam Mono CLM}
\setsansfont{Simple CLM}
% Use the following if you only want to change the font for Hebrew
%\newfontfamily\hebrewfont[Script=Hebrew]{David CLM}
%\newfontfamily\hebrewfonttt[Script=Hebrew]{Miriam Mono CLM}
%\newfontfamily\hebrewfontsf[Script=Hebrew]{Simple CLM}
\makeatletter
\makeatother
\usepackage{bidi}
\begin{document}
טקסט רגיל
\textbf{טקסט מודגש}
\textit{טקסט נטוי}
\textit{\textbf{טקסט מודגש ונטוי}}
בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ:
\begin{english}
In the beginning God created the heaven and the earth.
\end{english}
\sffamily
טקסט רגיל
\textbf{טקסט מודגש}
\textit{טקסט נטוי}
\textit{\textbf{טקסט מודגש ונטוי}}
בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ:
\begin{english}
In the beginning God created the heaven and the earth.
\end{english}
\ttfamily
טקסט רגיל
\textbf{טקסט מודגש}
\textit{טקסט נטוי}
\textit{\textbf{טקסט מודגש ונטוי}}
בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ:
\begin{english}
In the beginning God created the heaven and the earth.
\end{english}
\end{document}
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.
Continue reading nameref
Doesn’t Work Properly with Theorem Environment
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.
Continue reading Hebrew Support in Hyperref – Situation Review
Installing culmus-latex on Ubuntu 11.10
After someone complained to me that he can’t install culmus-latex on Ubuntu 11.10, I decided to check the issue. Apparently culmus-latex can’t be installed as-is on Ubuntu 11.10 (and probably other new versions of Debian and Ubuntu). The problem have been reported in few places such as Whatsup, but as I don’t frequent the forum lately, I wasn’t aware of it. Skip bellow if you’re just interested in the workaround.
Technical Details
The problem manifests itself as:
sudo make install
... snipped for brevity ...
mktexlsr: Done.
updmap-sys --enable Map=culmus.map
updmap: This is updmap, version $Id: updmap 14402 2009-07-23 17:09:15Z karl $
updmap: using transcript file `/var/lib/texmf/web2c/updmap.log'
updmap: initial config file is `/var/lib/texmf/web2c/updmap.cfg'
make: *** [install] Error 2
But if you look at updmap’s manpage there is no documentation for the return codes. Also there is no explicit place where it exits with return code 2 in the code. After some straceing I found the culprit in the combination of the set -e
in the top of /usr/bin/updmap
and the function pickLocalFile
in /usr/share/tex-common/debianize-upddmap
which overrides certain behaviors in updmap
. The pickLocalFile
uses the following lines
localfile=""
localfile="`ls $debDirname/*local*cfg 2>/dev/null`"
if [ -n "$localfile" ]; then
To check if there is a local configuration file under /etc/texmf/updmap.d
. If such file doesn’t exist, instead of creating one (as the maintainers of debianize-updmap
intended) it fails due to the set -e
in /usr/bin/updmap
. Thus updmap
exists with error code 2, instead of completing the installation.
Meanwhile, until the bug is fixed, there is a simple workaround
Workaround
Before installing, execute
sudo touch /etc/texmf/updmap.d/10local.cfg
And now the regular sudo make install
installation should finish successfully.
As the problem is a result of a Debian bug, I don’t expect to release a new version of culmus-latex, instead I’ll report the bug to the Debian team.
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.