“the j stands for Janizaries”
about me | research blog | wordpress plugins | jQuery plugins

5 September, 2014

De Gruyter fonts and LaTeX – the elusive DGMetaSerifScience.sty

I’m currently writing a paper which needs to conform to the De Gruyter format. The editor of the collection I’m submitting to asked us to use the Microsoft Word templates. Of course once you’ve used LaTeX there’s no going back to Word. De Gruyter themselves have on their website a LaTeX template which is freely downloadable and well documented.

The only issue is the fonts. De Gruyter have their own typeface family called De Gruyter Meta Science which looks very good and has great glyph coverage, but it is not free. Their guide explains that these fonts should be provided to you as an author by your editor. I asked, and I did in fact obtain these fonts in OTF format. Great. Except that to use them in the LaTeX template, you also apparently need some .sty files too. Quoting from the DeGruyter LaTeX template manual:

As already mentioned, dgruyter.sty checks whether the specific De Gruyter fonts are installed. More precisely, it checks whether a file DGMetaSerifScience.sty exists. If it exists, it presumes that the fonts DG Meta Science, DG MetaSerif Science, and the math font MinionMath are installed through the respective packages from De Gruyter. Otherwise errors will result.

The problem is, where do I get this .sty file from? I asked my editor, who sent me the fonts, but she had no idea about how to obtain them. After a lot of Googling and coming up with nothing, I decided to look into the details of the template file and try to figure out what this file should look like, so that I could create it myself. Turns out you actually need two .sty files which are almost identical, except in name. This is what I came up with for DGMetaScience.sty:

\ProvidesPackage{DGMetaScience}[2014/08/29]
\DeclareOption{lining}{
 \addfontfeatures{Numbers={Lining}}
}
\DeclareOption{proportional}{
 \addfontfeatures{Numbers={Proportional}}
}
\ProcessOptions\relax
\endinput

And an identical file called DGMetaSerifScience.sty where the package name is changed to reflect the file name. By having these files in the same directory as the rest of the LaTeX template I was able to successfully compile everything, and the result looks good. But who knows what else is contained in these elusive official .sty files, which I’ve omitted?

Disclaimer

The De Gruyter fonts themselves are clearly protected and I’m not making any attempt on infringing that. All I’m doing is posting my guess of what I think the associated .sty files should look like, in the hopes that someone else can find this useful. Or perhaps someone who has a better idea of this stuff can tell me what’s missing from my versions.

8 February, 2012

The sorry state of LaTeX editors: a manifesto

Firstly, I love LaTeX, I love coding, and I generally love feeling like a geek. Being able to produce beautifully typeset documents is hugely satisfying to me. But if you use LaTeX, you probably spend a good deal of your time actually writing markup rather than writing, well, words. Perhaps this is why LaTeX tends to be most popular in the computer science and engineering disciplines; you more or less need to have the skills and will of a coder to produce anything useful with it. But just because you can code, it doesn’t mean that you should always code.

Putting effort into your typesetting is a good thing. Producing elegant documents requires discipline and attention to detail, and LaTeX certainly gives you the right tools for exercising this discipline as far as you care to. But when you’ve set up your document layout just the way you want, defined your custom commands and prepared your reference and labels, it’s time to actually write.

Writing code and writing prose and two entirely different things. Even though LaTeX is a markup language, putting more emphasis on your actual text content that other paradigms, the truth is that its commands can quickly become unwieldy and dominate over the rest of your copy. And not being able to focus on what you are actually writing because of all the markup in the way is definitely a bad thing.

Writing with LaTeX requires two separate skillsets: markup-language programming and prose writing — but also one meta-skill: the ability to repeatedly switch back and forth between these two modes. Almost every tool or resource you’ll find in the LaTeX universe is focused only on the first of these skills, but never on the others. Nobody ever seems to bother promoting a writer-friendly environment for using LaTeX .

Every LaTeX editor I’ve tried has the same programmer-centric approach: split screen between editor/preview, syntax highlighting (which always breaks), brain-dead auto-completions, and the worst possible environment for writing you could ever imagine. LaTeX is capable of producing such beautiful output, why is it that writing LaTeX should be so painful and counter-aesthetic?

My first ever TeX IDE was TeXnic Centre, which I first used in 2009. Back then, it looked like Microsoft Office 1997. It doesn’t seem to have changed since. I floated between various basic text editors, TeXworks, Texmaker and Kile, each one pretty much as disappointing as the others. The first thing that annoys me is that in every single IDE, the auto-suggest is entirely dumb. Since they don’t do the dirty work of looking into your imported packages and determining what commands and environments they provide, your auto-suggestions are really only a list of default LaTeX commands. I understand that scoping into LaTeX packages is probably an absolute nightmare, but not doing so makes the auto-completions entirely useless. They also do some kind of reference processing to, so that when you type \cite{ you get a list of the things defined in your BibTeX file. Stop the presses. Quick-building and previewing is obviously nice, and some editors even do their best to jump to the newest addition in your freshly-compiled document. It’s never perfect, but it’s barely useful enough to prevent you giving up on life altogether.

There are now also a bunch of web-based TeX editors floating around, the most notable being ScribTeX. The advantages of not having to install LaTeX and deal with all those ridiculous intermediate files are clear. But guess what? They’re just clones of the desktop versions. Syntax highlighting, compilation/preview, and auto-completions that are only useful if you are not importing any other LaTeX package (read: useless). Their implementations may be elegant from a technical point of view, but they are not innovative in any way which I can see. But the biggest disappointment of all these LaTeX editors it that every last one of them completely disregards the notion that productive writing thrives in an environment that specifically promotes it; free from distractions and free from complicated markup.

What I’m basically talking about is the need for a distraction-free “Zen” editor. This is not a new idea, and many apps already exist for this — both OS-native (FocusWriter, WriteMonkey, Q10, WriteRoomOmmwriteriA Writer) and web-based (QuietWrite, Hallo, DarkCopy, PenZen, Koi). They all pretty much do the same thing, some with support for Markdown or RTF, but none of them seem to do anything about LaTeX. Full LaTeX support is understandably daunting – not even the so-called LaTeX Editors even support it fully. But just knowing when to show you code and when to show you content, just being able to succesfully handle the constant context-switching which LaTeX writers know all to well, for me is paramount. There is of course LyX, which does try to give you a WYSIWYG-like editing environment on top of LaTeX, although LyX itself is not simply an editor but a full-blown preprocessor. Truthfully, I have never tried it, although there are plenty of reasons why I don’t want to go down that road primarily the problems with collaborative writing and varying dependencies.

So, I am basically determined to build such an editor. Web-based by far the makes most sense, for compatibility. No cloud services or any other junk though; with HTML5 I’m hoping it shouldn’t be too hard to edit files right on your computer. Just a nice clean distraction-free TeX editor which knows when to show your syntax-highlighted TeX commands, and when to switch into “Zen” writing mode. As I thrash a proper prototype together I will launch a proper project somewhere and invite people to contribute. But you can consider this my manifesto.

Disclaimer

Firstly if I am wrong about any of the above, please call me on it. Particularly if some existing IDE is actually better than I have given it credit for, of if I failed to mention something significant altogether. Secondly, I want to know if things rings true with anyone else, or if I’m the one who is deeply disappointed by the LaTeX editors out there. It would be nice if this actually led to something half-decent one day. Finally, this post will change over time as things get pointed out to me and the ideas mature a bit.

9 May, 2010

Vertical alignment of inline images in LaTeX

This is one of those things which isn’t so easy to find, so here’s my contribution.

The Problem

You’re using LaTeX, and have a small image which you want to display inline with the text (i.e. not a float). So, you use something like the following:

...indicate whether the phrase you've constructed is valid (\includegraphics{tick.png}) or not (\includegraphics{cross.png}}). To make things...

This works, but often the vertical alignment is not quite right, as shown in the images below:

Inline images, non-aligned

Zoomed (x600)

The Solution

After some searching and experimenting, I found the best solution to be using the \raisebox command with a negative value, like so:

...indicate whether the phrase you've constructed is valid (\raisebox{-1mm}{\includegraphics{tick.png}}) or not (\raisebox{-1mm}{\includegraphics{cross.png}}). To make things...

The additional code is minimal and it works perfectly (as far as I can tell). Results as below:

Inline images, properly aligned

Zoomed (x600)

3 May, 2010

Mendeley, BibTeX and citing Website URLs

The Problem

  1. Using Mendeley Desktop (<3) to manage all my dissertation references, which automatically writes a BibTeX (.bib) for me which I include in my LaTeX document. So far so good.
  2. When I manually create an entry in Mendeley for a website, it creates a BibTeX entry like the following:
    @misc{myKey,
    author = {Surname, Name},
    title = {{Website Name}},
    url = {http://my.url.com/},
    year = {2010}
    }
  3. That looks fair enough, but standard BibTeX/LaTeX simply ignores the url field in the entry… which makes the reference look rather stupid. So how can I handle websites properly?

What I hoped I would be able to find

  1. I wish Mendeley had some more advanced options which controlled how BibTeX files were created, this would have definitely been the most ideal option, but alas no such options exist. Editing the generated .bib yourself would be pointless since Mendeley will just overwrite the file each time.
  2. BibTeX itself could really do with an update in the website-citation department. I’ve seen lots of talk about new versions but can’t see where they are… Also I know there are alternative BibTeX packages which can be used, but this was something I wanted to avoid because sometimes you can’t tell what else it’s going to change in your references. For more information on the options, I recommend this link: URLs in BibTeX bibliographies

The Solution

  1. The best solution I could come up with so far, is to simply delete these references from Mendeley and put them in your own custom .bib file. Thus, you will have the Mendeley-generated bib file (which we’ll call mendeley.bib) and your own custom bib file for website entries (which we’ll call websites.bib)
  2. When writing your BibTeX website entries, be sure to use the howpublised field like so:
    @misc{myKey,
    author = {Surname, Name},
    title = {{Website Name}},
    howpublished = {\url{http://my.url.com/}},
    year = {2010}
    }
  3. This will get BibTeX to correctly show the URL in the bibliography entry.
  4. Finally in your LaTeX document be sure to include both bib files, like so: \bibliography{mendeley,websites}

An Alternative

Actually, what I ended up doing in my dissertation is listing these “one-off” website references as footnotes rather than actual citations, since they’re not exactly publications. Obviously you will have to see whether this is applicable or not to you.

22 September, 2009

LaTeX underlines in uneven positions?

Just started using LaTeX, and it annoyed me how the vertical-alignment of the \underline{} tag is not always the same, depending on whether the text ‘dips downwards’ or not (don’t know the correct term).

Anyway I found a fix, basically use \usepackage[normalem]{ulem} in your preamble, and \uline{My Text} instead of \underline{} in your normal text.

via Getting to Grips with Latex – Formatting – Latex Tutorials by Andrew Roberts @ School of Computing, University of Leeds.
http://blog.johnjcamilleri.com/category/latex/
blog.johnjcamilleri.com
crawl=CC-MAIN-2017-30
31841
application/http; msgtype=response
sha1:RTLESRJ4EXKK32UB4S3W5APK3KX7AWJO
<urn:uuid:aebf2254-1348-4cd2-bc27-bedb8e58c147>
2017-07-22T18:51:33Z
77.235.50.85
application/xhtml+xml
sha1:FLWHZKGADKYWEUISMFR5HG3YZ6JJO7SR
<urn:uuid:3dfbb9d9-5c05-424f-bc6f-e1e21e717322>
http://blog.johnjcamilleri.com/category/latex/
length
response
<urn:uuid:6b02d896-c526-414e-b650-821c2a4540b9>
robots: classic
hostname: ip-10-147-8-133.ec2.internal
software: Nutch 1.6 (CC)
isPartOf: CC-MAIN-2017-30
operator: Common Crawl Admin
description: Wide crawl of the web for July 2017
publisher: Common Crawl
format: WARC File Format 1.0
conformsTo: http://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1_latestdraft.pdf