You do not want to mess up, right? When writing a LaTeX document, you may once in a while want to include some Matlab codes and/or outputs (preferably typeset using typewriter font if you have the same taste as me)… Continue Reading →
Since I started my PhD I have forced myself to use LaTeX for all of the documents that I write (yes, absolutely everything), and this has really helped me get to grips with how to do things in LaTeX. Overall… Continue Reading →
Non-textual tabular requirements I once wrote a procedure for drawing tabulars with square cells; it was one of my earliest experiences with LaTeX programming, actually. When I’d done so, I received a comment ‘why doesn’t LaTeX allow this easily’? Well,… Continue Reading →
It’s probably fairly uncontroversial to say that floats are one of the main areas where LaTeX performs poorly in comparison to WYSIWYG editors. The basic complaint is that floats just don’t go where we want them. To compensate for this,… Continue Reading →
Somewhat mysteriously, in the middle of the chapter on macros in The TeXbook, Knuth defines \rhead—the macro he uses to keep track of the running headline. The definition itself is a little odd in that when \rhead is executed, it… Continue Reading →
Recent versions of pdfTeX contain primitives for generating random integers. \pdfuniformdeviate num generates a uniformly distributed random integer in the range [0, num). \pdfnormaldeviate generates a normally distributed random integer with mean 0 and “a unit of 65536”. (I’ve never… Continue Reading →
When quoting Lamport about writing Greek letters being as easy as writing “… as easy as $\pi$” in The TeXbook, Knuth cites the book as LaTeX Document Preparation System. He comments, Note: the final manual has a slightly different wording… Continue Reading →
I’m using the new rotation option for cycles to define a macro that draws a flower snark. The macro has as optional arguments the radius RA, RB, and RC of the three types of vertices, and a mandatory argument which… Continue Reading →
\grEmptyCycle and \grCycle can also have options x and y, that set the coordinates of the center of the cycle, or r and d for polar coordinates (r is the radius and d the angle). Here we use these options… Continue Reading →
Finally, the much expected new versions (1.00 c) of tzk-graph and tkz-berge were released by Alain Matthes last week, and can be downloaded from Altermundus download zone. I expect to post several examples using the new capabilities of the packages…. Continue Reading →
The latest version of fontspec now returns proper error messages when a font cannot be found: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ./small.tex:6: ! fontspec error: “font-not-found” ! ! The font “Ggeorgia” cannot be found. ! ! See the fontspec documentation for further information. !… Continue Reading →
The latest issue of the PracTeX Journal (discl.: I used to be a production editor there some years back) contains a set of interesting challenges: typeset and solve a KenKen puzzle. I haven’t seen this puzzle before; it looks fun… Continue Reading →
Trends in recent years for texhax and the Mac OS X TeX mailing lists. And a comparison with tex.stackexchange.com. Manuel Pégourié-Gonnard asked whether I’d looked at the number of posts to the texhax mailing list when I posted last night… Continue Reading →
With new LaTeX sites around nowadays such as tex.stackexchange.com and latex-community.org, it seems that the comp.text.tex newsgroup, the mainstay of the TeX support world, is in decline. Newsgroups in 2011 are an anachronism from the younger days of the internet,… Continue Reading →
Funny problem in mathtools vs. francais babel. (Only a coincidence that I’m debugging two babel problems back-to-back.) Morten Høgholm’s mathtools package has an option to turn the colon into an active character so that writing := produces a colon-equals sign… Continue Reading →
A user of Peter Wilson’s fonttable package reported an interesting bug in the interaction between it and the Spanish module (if not others) of babel. Here’s the problem in a nutshell: \documentclass{article} \usepackage[spanish]{babel} \begin{document} $\lim x_n$ {\font\x=cmr10\x hello} $\lim x_n$… Continue Reading →
Some time ago, I gave recommendations for packages to use to produce output in Times roman fonts (and others that look nice with Times). Doing this has the downside that certain aspects of the Times math fonts are really ugly…. Continue Reading →
One of the most commonly asked questions is how to change font sizes in LaTeX beyond those offered by \tiny through \Huge. There are a number of different font parameters that can be selected using the New Font Selection Scheme…. Continue Reading →
Here’s a great one from the source code to TeX. It’s the beginning of section 1154. The simplest math formula is, of course, ‘$ $’, when no noads are generated. The next simplest cases involve a single character, e.g., ‘$x$’…. Continue Reading →
The vertices that tkz-berge draws are regular named TikZ nodes, and so they can be used if one wants unusual edges. Update: I added four more lines, to show that one can also use the node names provided by tkz-berge,… Continue Reading →
Okay, this one isn’t a comment in code, yet it amuses me anyway. This is Exercise 24.1 in The TeXbook. Can you think of a reason why you might want ‘A12’ to be a ‹hex digit› even though the letter… Continue Reading →
Scattered throughout Knuth’s programs are a number of great comments. I really enjoy encountering these and I thought I’d share them. (As I wrote in my first post, this blog is mostly a way for me to collect pieces of… Continue Reading →
As currently implemented in LaTeX, \mbox and \fbox (among others) have a bizarre limitation: their arguments cannot change category codes. One practical consequence of this is that \verb is not allowed in the arguments. This limitation is completely artificial and… Continue Reading →
Two things that annoyed me with making LaTeX packages using a .dtx file were the duplication of the copyright/license info and that nearly every line in the file was commented out. About the only thing that wasn’t commented out was… Continue Reading →
The macro \EdgeDoubleMod is convenient when drawing some complicated graphs. Consider the following picture of the line graph of the Petersen graph. produced by: \begin{tikzpicture} \SetVertexNormal[MinSize=12pt] \tikzset{VertexStyle/.append style= {inner sep=0pt,font=\footnotesize\sffamily}} \begin{scope}[rotate=-90] \grCirculant[RA=0.6,prefix=a]{5}{2} \end{scope} \begin{scope}[rotate=-18] \grEmptyCycle[RA=1.5,prefix=b]{5}{2} \end{scope} \begin{scope}[rotate=18] \grCycle[RA=2.5,prefix=c]{5} \end{scope} \EdgeIdentity{a}{b}{5}… Continue Reading →
I’m not totally sure why one would want to center the last line in a paragraph, but the excellent TeX by Topic provides a surprising solution. \leftskip=0pt plus.5fil \rightskip=0pt plus-.5fil \parfillskip=0pt plus1fil The reason this works is that for all… Continue Reading →
The simplest way to count the number of lines in a file seems to be to use the ε-TeX primitive \readline. (One could probably get away with using the TeX primitive \read instead, but that reads lines according to the… Continue Reading →
Unfortunately, the current version of pdfTeX is lacking a \expanded primitive that would fully expand its argument, similar to the full expansion that happens for the replacement text of an \edef. However, there is a trick that will keep expanding… Continue Reading →
Everybody loves a good quine. The most obvious, and most cheating way to write a “quine” In LaTeX is to use the listings package. \documentclass{article} \usepackage{listings} \lstset{language=[LaTeX]TeX} \begin{document} \lstinputlisting{\jobname} \end{document} This is not very exciting and it’s cheating on two… Continue Reading →
The TeX primitive \number will convert anything that can be converted to a number into a decimal number and what’s more, it is expandable. That is \edef\foo{\number\count37} will define \foo to be whatever the value of count register 37 is…. Continue Reading →
As LaTeX tutorials are quick to point out, \vspace{x} can disappear at the top or bottom of pages. This is because each \vspace expands to two \vskips which are discardable. Thus, if you write \vspace{3in} near the bottom of the… Continue Reading →
By popular demand, here is the Sieve of Eratosthenes written in Plain TeX. \newcount\cm\cm100 \newcount\ci \newcount\cj \def\prime{prime} \def\composite{composite} \def\set#1#2{\global\expandafter\let\csname s\number#1\endcsname#2} \def\get#1{\csname s\number#1\endcsname} \def\doprime{% \set\ci\prime \cj\ci \loop \advance\cj\ci \ifnum\cj<\cm \set\cj\composite \repeat } \ci2 \loop\ifnum\ci<\cm \expandafter\ifx\csname s\number\ci\endcsname\relax \begingroup \doprime \endgroup \fi \advance\ci1… Continue Reading →
In C, if you pass in a pointer to a function, the content of the involved variable may be changed. In Matlab, however, if you pass in an array as an argument, the content of the array will never be… Continue Reading →
As previously mentioned I gave a talk at Melbourne R Users Group titled “Reproducible Research and R Workflow”. It covered technologies including LaTeX, Sweave, R, make, Eclipse, and git. This post shares the video. I’d like to thank Pedro Olaya… Continue Reading →
I gave a presentation at Melbourne R Users on the topic of R Workflow. The presentation covered R code organisation, and useful R related tools including Eclipse, StatET, Git, make, Sweave and LaTeX. Also, the slides from the presentation provide… Continue Reading →
This post provides an example of using Sweave to perform an item analysis of a multiple choice test. It is designed as a tutorial for learning more about using Sweave in a mode where console input and output is displayed…. Continue Reading →
This post documents an example of using Sweave to generate individualised personality reports based on responses to a personality test. Each report provides information on both the responses of the general sample and responses of the specific respondent. All source… Continue Reading →
This post provides information on (a) installing Git using the Eclipse plugin Egit. (b) uploading repositories to GitHub, and (c) links to resources on Git, Git and LaTeX, and Git and R. The focus is on version control for people… Continue Reading →
In this post I present an example of using Sweave to prepare a PDF of formatted multiple choice questions. More broadly the example shows how to use Sweave to incorporate elements of a database into a formatted LaTeX document. It… Continue Reading →
This post provides a brief introduction to make and makefiles. In particular it describes how to set up make on Windows with an emphasis on using make in Eclipse on projects involving R, Sweave, and LaTeX. Overview make is software… Continue Reading →
LaTeX and mathematics go well together. At the risk of preaching to the converted, this post sets out (a) reasons to learn to write mathematics in LaTeX, (b) a few free internet guides on learning to write mathematics in LaTeX,… Continue Reading →
Someone asked about the architecture of LaTeX. After avoiding the question for a day, I decided to answer. Since it’s possible the question will be closed and possibly deleted, I figured I’d reproduce the relevant portion of my answer here…. Continue Reading →
I have two versions of my cv: one for public consumption and one which contains extra private bibliography entries for work that is in submission. Obviously these are mostly the same so I had one one that had a \newif\ifpublic… Continue Reading →
On occasion, one has cause to compare two boxes and compute the maximum of the two widths. If the two boxes are 0 and 2, then the standard way to do that is something like \ifdim\wd0>\wd2 \dimen0 \wd0 \else \dimen0… Continue Reading →
This post provides a guide to getting started with Beamer, a popular LaTeX package for preparing slide presentations. The post: (a) Lists some of the benefits of Beamer in comparison to PowerPoint; (b) Links to tutorials and suggestions for learning… Continue Reading →
For those who don’t already know, Beamer is a useful package in LaTeX for preparing slide presentations. I have a Beamer template of preamble and slide templates. I found having a template was useful: (a) when first learning Beamer commands,… Continue Reading →
The code should be self-explaning.. function y = f(x) y1 = x.* (x<0); y2 = x.^2 .* (x>=0) .* (x<2); y3 = 4 .* (x>=2); y = y1 + y2 + y3;
This post discusses my experience with WinEdt 6.0 as a text editor for writing documents in LaTeX. In this post I outline: (a) Why I have chosen to use WinEdt; (b) The role of WinEdt in my workflow; (c) Various… Continue Reading →
© 2025 TeX.social