Skip to content →

Tag: mac

latexrender plugin for wordpress under tiger

Promises and pie-crusts are made to be broken, a wiser man once
said. Still, promises have a much longer life-span and sometimes their
real content becomes redundant over time.

A year ago, I
promised
to document how I got the
LaTeXRender Plugin for WordPress
working under OS X. The procedure
consisted of some trial-and-error operations, installing non-standard
versions of software and hardcoding certain directories throughout
certain files…

Not something I was looking forward
to when I decided to upgrade this WordPress blog but,
surprisingly, things went pretty smoothly this time (Mac-technology
has improved a lot). So, please don’t worry too much about this
post
and follow the (late) instructions below.

First
things first : I will assume you have the ‘generic’ LaTeX
running under Tiger (10.4),that is, use the i-Installer to download BOTH
LaTeX and Imagemagick! Further, in order to get WordPress up and
running, have the standard
MySQL 4.0 package
installed for 10.3 (not version
4.1…) and don’t use the generic Mac-PHP version, but
instead download Marc
Liyanage’s PHP5 package
which has plenty of additional
packages installed (notably, GDlib and MCRYPT which comes in handy if
you want to fight spam-comments using BotCheck).

\r
\n

Download wp-
latexrender.zip
and follow the instructions given to the letter
(there is one undocumented extra directory you have to fill in at the
start of the latexrender-plugin.php file). There is
just one additional thing to do. Find in the
class.latexrender.php file the line starting
with

// convert dvi file to postscript using
  dvips

and include the following lines just before it
:

// begin of workaround // extending the PATH
  environmental variable Soldpath =
  getenv(“PATH”); Swhere_imagemagick_is =
  “/usr/local/bin”; if (Soldpath) { Swhere_imagemagick_is .=
  “:Soldpath”;} putenv(“PATH=Swhere_imagemagick_is”); //
  end of workaround 

activate the plugin and it
should work! Still, there are three things you may want to change. In
the latex.php file uncomment the indicated lines as
you will be using htmlArea to input your posts. In addition, if you
have the MarkDown-plugin enabled, it is best to append additional
lines such as

 Slatex_formula =
  str_replace(“_”,”_”,Slatex_formula);     Slatex_formula
  =
  str_replace(“_”,”_”,Slatex_formula); 

(
between the first ” ” should be the beginning and end
em-tag respectively) or underscores will be interpreted as em-tags.
If you run into additional similar problems, the procedure is to
comment-out the line

 
  unlink(Sthis->_tmp_dir.”/”.Sthis->_tmp_filename.”.tex”); 
  

near the end of class.latexrender.php , look in the
tmp directory for the TeX-file, detect the problem and add similar
lines to the ones above to solve it. Another useful thing to do
is to add TeX-packages in the class.latexrender.php file. My own
version has the following predefined symbols and loaded
packages

 function wrap_formula(Slatex_formula) { 
  Sstring  =
  “\\documentclass[“.Sthis->_font_size.”pt]{“.Sthis->_latexclass
  .”}\\n”;  Sstring .=
  “\\usepackage[latin1]{inputenc}\\n”;  Sstring .=
  “\\usepackage{amsmath}\\n”;  Sstring .=
  “\\usepackage{amsfonts}\\n”;  Sstring .=
  “\\usepackage{amssymb}\\n”;  Sstring .=
  “\\usepackage{xy}\\n”;  Sstring .=
  “\\xyoption{all}\\n”;  Sstring .=
  “\\\\newcommand{\\vtx}[1]{*+[o][F-]{Scriptscriptstyle
  #1}}\\n”;  Sstring .= “\\\\newcommand{\\mathbb{C}c}{\\Bbbk}\\n”; 
  Sstring .= “\\\\newcommand{\\mathbb{C}}{\\mathbb{C}}\\n”;  Sstring .=
  “\\\\newcommand{\\mathbb{Q}}{\\mathbb{Q}}\\n”;  Sstring .=
  “\\\\newcommand{\\mathbb{Z}}{\\mathbb{Z}}\\n”;  Sstring .=
  “\\\\newcommand{\\mathbb{N}}{\\mathbb{N}}\\n”;  Sstring .=
  “\\\\newcommand{\\mathbf}[1]{{\\\\text{\\em \\usefont{OT1}{cmtt}{m}{n}
  #1}}}\\n”;  Sstring .= “\\pagestyle{empty}\\n”;  Sstring
  .= “\\begin{document}\\n”;  Sstring .=
  “S”.Slatex_formula.”S\\n”;  Sstring .=
  “\\end{document}\\n”;          return Sstring;     }  
  

which, among other things, allow all commenters to add
quiver-pictures using xymatrix and vtx to depict vertices. Oh yes, you
can allow comments to include LaTeX-code by uncommenting the
line

  // add_filter(‘comment_text’,
  ‘addlatex’); 

in the latexrender-plugin.php
file (but before you do make sure you have spam under control, such as
with BotCheck mentioned above). That’s all for now. If you want
to use TeX in a comment, make sure to put the code between tags [ tex
] and [ /tex ] (omitting the extra spaces). If you want me to add
other LaTeX-packages, leave a comment.

Leave a Comment

publish

A quick reply to some of the comments
to the lulu/neverendingbooks post.

_Are they also
responsible for the graphical design in your books ?_ No! In fact it
was one of the more pleasant experiences of the last couple of weeks to
develop our own format, LaTeX-style and covers. The usual gang had their
say in all of this but it is only fair to say that Jan did most of the work. We developed
the cover-concept (that is, macro shots of games in duotones and placing
of titles etc) by trial and error. Jan is responsible for the
photo-shoot, I did choose the shots to be used and did the initial
coloring and placing of titles and left the final tweaking to Jan, who
did some lay-out work before. We, at least, are happy with the
result… As mentioned before, the LaTeX-style sheets were made
using the
memoir package
.

_Who is responsible for trying to sell
the book, you or them?_ I dont think we are doing great efforts to
try to sell the books, yet. Up to now, you can only get to the
book-sites via this blog or via my homepage. Lulu claims that they will only make
money if we do… and as this is clearly sales-talk (they make money
on every book they print) it involves no (or a very small) financial
risk on our part. Anyone who wants to have a copy of one of our books,
orders them at Lulu, they print it and ship it to you. But beware! They
have several shipping options and for most of them it costs you more to
get them shipped than to buy the books… In fact, that was the main
reason why we didnt put the URL online before we had two volumes out.
The reason being that if you buy for over 25dollars you can have them
shipped via their “SuperSaver” option, that is, shipping is free (but
probably slow). But, based on my own experience it works well (I ordered
a few copies of book 1 via SuperSaver and another one via their
InternationalShipment and got the free SuperSaver package a day before
the costly other shipment…). Our real investment is that we have
bought ISBN-numbers for the books (at a price of 35dollars/book) and
hope to earn this back from a small royalty we get from each book (the
Lulu-rule is that they get 25% of any royalties you set). Even though we
are not entirely happy with the distribution process we opted for this
series for an unusual book-format making it handy and fun to use (the
square 7.5 x 7.5 inch format is very pleasing to read and the
coil-binding makes it extremely handy to lay flat on the table). So we
view this series as a student-edition of the books and we keep them as
cheap as possible. At a later stage it may happen that we will also have
a library-edition of the books which will have global distribution
(meaning that you can order them via Amazon or your local bookshop). For
this to work, you have not so much freedom in your book-format and can
only have regular binding. Besides, buying such a global-ISBN is more
costly and will make this edition (a lot) more expensive. But, as you
can see from the picture, the books get printed and shipped and look
VERY nice. In fact, of the few copies I ordered, I had to hand out
already two because some people just liked the feel and touch of it. I
think, people will only gradually be willing to buy their own copy when
(1) they have glanced through a copy at some meeting or seminar and (2)
if more volumes come out and they have a greater choice in bying 2
volumes to get free shipping. On this last issue : already three people
have expressed interest in writing a book in our series. My own hunch is
that the next book out will have to do with Poisson noncommutative
geometry and will have a macro shot of a war-game on its cover (authors
can give suggestions for which games they want on their cover), curious
how this will work out…

_How many have you sold so
far?_ Well, not enough so far to get our ISBN-investment back…
But, once again, I think it will take some time for people to trust the
series enough to buy a volume or two. In the first week we made the URL
available we sold 16 books, so if you want to increase our sales-index
please do by going to this
page
for the first volume and to this page for the second
volume. But perhaps it is easier to bookmark the lulu/neverendingbooks if
you want the latest news on the series. I”ll keep you posted on our
sales via this page. If you buy a book and like the result, please tell
others about it (or even better, let them see and feel the copy.
Hopefully you will get it back…)

Leave a Comment

color schemes

In the unlikely event that we will ever be publishing a
_series_ of books, we’d better have a strategy to design the
_next one_ as we don’t want to go through this time-consuming
process each time. So we need a concept, a consistent
lay-out and a consistent color scheme.

Think of the O’Reilly
hacks books
. Their concept is to have a white background with a
black&white photo of a tool on it, their layout is : a huge colored
title at the top and the authors at the bottom, their color-scheme is
set according to the topic but always using just one color! Pretty
simple, but extremely effective in creating a common look-and-feel for
the series.

Our concept is to take a macro photo of a
mathematical game in duotone
.

Clearly, the game will vary throughout the series and may
even depend on the author (the example-game is Gipf). Duotone (that is,
converting the photo to grayscale and replacing white by another color
and adjusting saturation) because we are no graphic designers and have
no control on the final result if we would go for something more
involved.

Of course, the second color will also change
throughout the series. As we have no time to read interesting books such
as the color harmony workbook we just went for a
variation of the triad
color idea
. That is,

Any three colors
with a balanced triangular relationship are triads. The basic triad
consists of three colors equidistant on the color wheel. The best known
of all color schemes are: the primary colors, red, yellow, and blue; the
secondary colors, orange, green and violet; and the remaining tertiary
colors, like red-orange and blue-violet. Triadic colors are usually
considered pleasing to the eye.

Given the
first color, we add first 120 and then 240 to its hue-value. For the 4th
color we take the opposing color (+180) and the 5th and 6th colors make
a second triad. For the 7th color we then have to go for +150 and form
another triad and so on and so on. An example of how such a series might
look is given at the top.

Finally, as for the lay-out, well,
it’s far from perfect but it’s the best we managed to do before
we got fed up with it. But, perhaps you might appreciate the stylish
hyphens in subtitle and in the numbering line, compatible with our own
chapterstyle.

Leave a Comment