## Flagging: Helping your moderators

2012-09-23 by . 2 comments

Members of Tex-sx with enough ‘reputation’ can flag questions and answers for moderator attention. That’s an important part of how the site works: the moderators cannot read everything. A few posts gets flagged as spam or similarly out-and-out unwelcome material, and they are easy for the moderators to deal with. However, most flagged posts need a bit more work, as often they are suggested duplicates, off-topic entries or similar.

Over the life of the site, it’s been clear that users appreciate some feedback on moderator action, whether that’s closing a question or dismissing a flag without doing anything. That’s what the comment system is for, and so I leave a lot of comments! It’s particularly important that questions that get closed have an explanation: the ‘stock text’ added by the system when a question is closed is okay, but is best when backed up by something more direct.

What I’d therefore suggest is that when you flag a post, consider adding a (friendly) comment too: we have a good set of ‘stock’ ones. When one of the mods then comes along, they’ll have one less thing to think about before acting

Ah good, there’s already a comment suggesting that this question is off-topic/a duplicate/…, so I don’t have to add one :-)

It’s a small thing, but it’s also very much appreciated!

Filed under TeX.sx

2012-09-21 by . 9 comments

## Introduction

Those who have read my previous posts will not be surprised that I am writing this in LaTeX. Nor that I am writing this on my iPad. I’ve done both before. What is different this time is that I can compile the document on my iPad (“Look Ma! No cloud.”) to see what it will look like[^1].

This is thanks to a new iPad application called TeX Writer (UK store).

more »

Filed under Editors, LaTeX

## TeXtalk: an interview with Joseph Wright

2012-09-14 by . 1 comments

Hello there, welcome to the TeXtalk! We have a very special guest for today: our friend Joseph Wright, one of our TeX.sx moderators, 60k+ rep, 415 badges, member of the LaTeX3 team, member of the biblatex taskforce together with Philip Kime and Audrey Boruvka, author of the amazing siunitx package, and an avid blogger on TeX matters. Get ready for this awesome interview!

more »

Filed under Interviews

## A perl script for indenting .tex files

2012-08-29 by . 9 comments

As LaTeX users we are confident that the output of our documents will almost always be beautiful. Best practices also dictate that we try to construct our code to be as robust and portable as possible; one of the things that sometimes gets overlooked, especially when working on larger documents, is the somewhat-tedious task of indenting source code, and aligning delimiter tabs.

Of course, some editors do this kind of thing for us; for example, vim users can (in Normal mode)  press gg=G which will indent the code automagically (although this action doesn’t align the delimiter tabs); I’m sure it can be done in other editors too. I had also read LaTeX code sniffer and or beautifier but found the linked Perl script didn’t behave as I wanted it to.

So, I found that I was interested in taking my own approach that I could ‘easily’ customize, which is why I wrote the Perl Script indent.plx which can be found at https://github.com/cmhughes/latexindent.plx. Note that you should click on “indent.plx” and then download it by clicking on the “Raw” button.

## Demonstration

We’ll talk about how it works a little later, but first here’s a visual demonstration of what it does. Let’s say that we have a block of code that uses alignment delimiters, something like the align, or tabular environment that we know and love. Some typical source code might look like the following:

Of course, if we’re working on a small document (or posting an answer to tex exchange) and had a fair bit of time, then we might take the time to align all of the &, but it’s not usually a good use of our time.  If we’re working on a larger document, perhaps a chapter file that has around 10,000 lines, then taking care of such alignment is extremely tedious and probably not very worthwhile, especially early in the editing process.

After running the above code through indent.plx, we obtain

which, I hope you’ll agree, is a lot nicer to look at.

Here’s another example- a fairly standard TikZ picture; this example demonstrates that nested environments indent as we wish. First of all, here’s the code we start with (ugh!)

and after running it through indent.plx, we obtain the following

## How does it work?

The script loops through the input file, and checks for matches of the form \begin{.*} and \end{.*}. If it finds a match, then it will (by default) add a level of indentation for the block within the environment. If there are environments that you don’t wish to have indented, then you can specify them at the beginning of indent.plx; furthermore, if you have a special rule for indentation of a certain environment (perhaps double tab? or a single space?) you can specify that as well.

If the environment matches one that has alignment delimiters, such as tabular, align, or any other type that you specify, then the block will be stored for processing in the subroutine format_block. This subroutine loops through the rows, splits each row at the &amp; and measures the size of the column. This allows it to output to a formatted string using sprintf.

The script will also match commands such as \parbox{} that may split their braces across lines, provided that the opening brace starts on the same line as the command, \parbox{... and the finishing brace finishes on its own line.

The script is mainly designed for ‘chapter’ files; by default it will not operate on the preamble.

## Is this script for you?

Possibly :) Hopefully. But maybe not. Whenever you’re working with a script that modifies a text file, you should be very careful. Before you try it out on your important documents, try it on the file sampleBEFORE.tex and see what you think. Inspect the code, and see if my (what I hope is fairly orthodox) style fits with yours. If it does, then take it for a spin on one of you own files- but please always make a back up first! The script does work in a lot of situations, but there are others when it may fail, I don’t claim that it will work for every .tex file ever produced.

## How do you use the script?

If you’re on .*nix then you can run it from the command line using

perl indent.plx myfile.tex

and if you want to output to a file, then you can use

perl indent.plx myfile.tex&gt; outputfile.tex.

Of course, you could make it executable (chmod +x indent.plx) and put it with your other executable files- I use /usr/local/bin but other choices are available.

Windows users need a Perl installation. Paulo’s excellent answer to How to make the rmligs script available globally on windows will be helpful.

## Moving forward

As a huge fan of open source material, I encourage anyone and everyone to dive in and make improvements. If it’s useful enough that anyone would like to collaborate and improve the script, I’d be very interested in doing so. For the moment, let’s communicate through the chat here on tex exchange.

I hope it’s useful; if it’s not directly useful, I hope that perhaps it gives you an idea of how you might make it useful, or create something of your own :)

Final disclaimer: I don’t claim to be a Perl expert- I’m sure that the code could be improved :)

Filed under LaTeX, TeX.sx, Workflow

## TeXtalk: an interview with Aditya

2012-08-16 by . 0 comments

Welcome to the TeXtalk! We have a very special guest for today: our friend Aditya Mahajan, one of the most active members of TeX.sx, 18k+ rep, 91+ badges (including the ConTeXt badge), 310+ answers so far, and our resident ConTeXt expert. Get ready for this awesome interview!

more »

Filed under Interviews

## Maintaining a balance

2012-08-10 by . 2 comments

Keeping the TeX-sx site working well is a balancing act. We want good quality content, and that means there is housekeeping to do: voting, editing questions and answers, looking for duplicates and adding comments. At the same time, it’s important that users are not put off by being told for example that their question has been asked before. On the main StackOverflow blog, there’s a post about how they’ve approached this: it’s raised quite a lot of comment. Each StackExchange site has its own approach to these issues, and so I thought I’d look at what the TeX-sx approach seems to be.

A key aim is to make the site accessible to new users, whether they are new TeX users or not. That means giving people some leeway when they ask questions or post answers: very rapidly closing is not normally the best plan. Many TeX questions are focussed on single documents, and teasing out the required detail is something that the questioner often needs some guidance with (they are often under pressure to get things done!). Of course, there is still a need to keep on top of material which needs improving. That’s one of the reasons for the Answer the Unanswered sessions: it lets us keep on top of questions where improvements were needed and did not happen.

It’s a similar story with voting: in general, we’ve tried to avoid downvotes. Voting on TeX-sx is hopefully about being positive: good questions and answers get upvotes, and less good ones don’t. Some really poor material might deserve a score of minus one, but beyond that there’s no value in downvoting.

Editing material is something that needs a bit of care: every question and answer has someone’s name on it, even if it’s been edited. Again, the feeling has been to keep a balance between the needs of readers (to have well presented material) and of original authors (to have their efforts respected). That’s led to some questions, but in the round I think we’ve not done badly.

So what’s the message? Remember that there are many different site users, with many different requirements. We want good content, but we also want a welcoming site where new users feel they can contribute.

Filed under TeX.sx

## TeXtalk: an interview with PLK

2012-08-06 by . 0 comments

Welcome to the TeXtalk! We have a very special guest for today: our friend Philip Kime, also known as PLK, our biber/biblatex expert. He’s the project leader of the biblatex task force, together with Audrey and Joseph Wright, and a great Perl programmer. Get ready for this awesome interview!

more »

Filed under Interviews

## TeX and GNU Emacs: A simpleton’s journey

About four months ago, I asked this question on TeX-sx. Over the previous ten years, I had looked at GNU Emacs, as a programming editor, three or four times, and, each time, given up because I thought the learning and implementation curves too challenging.

But this time, encouraged by the helpful answers to my question, I decided to invest some time in learning Emacs and tweaking it to do what I wanted. And now, four months later, I’m really pleased with the journey so far.

### Background

I’m a Windows 7 user, using TeX Live and Emacs 23.3 for Windows. As a specialised software developer, my main TeX products are proposals and design documentation (though I also use it for all my ‘domestic text processing’ tasks). I generally manage documentation source, and everything else in a project, with Git.

### Editing documents with Emacs

Plain Emacs out-of-the-box does a wonderful job, but for TeX editing you need a bit more: AucTeX, which provides many useful tools for TeX editing, including a component, RefTeX, which presents you with an intelligent TOC right there in your editor, allowing you to navigate (across multiple input files, of course), and to create index entries, labels, and cross-references very easily. AucTeX also has an outlining component which allows you to fold up your section hierarchy.

Just to whet the appetite, here’s a screen shot of a (fully unfolded) piece of a RefTeX toc:

As well as using Emacs for TeX editing, for notes and brainstorms I can heartily recommend org-mode, which is (much more than) an outliner, with facilities for To-Do items and table manipulation, as well as the usual structural organising.

It took some time to get Emacs tailored exactly to my liking. It’s a bit like typography in that respect; there are always opportunities for ‘just one more tweak’, and a lot of self-control is needed. But you should expect to do some customization, perhaps with help from SO or TeX.se.

### Things I have not been able to do

The main reason for these, I think, is that my perception of the effort and irritation needed to get x working exceeds the effort and irritation of ignoring it or inventing a work-around. Here are the principal ones:

• Unicode support from the keyboard: I occasionally work in multiple languages, including Welsh and Turkish, which are not catered for by ISO-8859-1. I have a customised Windows keyboard layout which generates the right Unicode characters, but Emacs, despite hours of cutting and pasting tentative solutions from the Internet, still insists on shoehorning them into ISO-8859-1: ŵ becomes w, ğ becomes g, and so on. I’ll live with it.
• I haven’t tried to get Emacs to run LaTeX and produce a preview for me — I use Texworks for that, editing a dummy file which simply points to my master document file. One day…
• I can’t seem to get references to labels in other files of the same book to work. One day…
• Doing anything to the *toc* (refreshing, for example) always seems to split the screen. Just grin and bear it.

### Summing up

Emacs is a fantastic editing system, and I’m gradually moving all my editing over to it from Notepad++ (something I never imagined doing). I confess to feeling a bit dizzy with all the new key combinations (I sometimes try to close other things with Ctrl-X Ctrl-C), but I’m really overjoyed at having made the move. I know Emacs isn’t for everyone, but if you’re not completely satisfied with your current editor, you really should consider it.

Filed under Editors, Workflow

## A new open font: Adobe Source Sans Pro

2012-08-03 by . 6 comments

Using TeX is about more than just the TeX document itself: fonts are a big part of producing high quality documents. One of the issues facing all fans of typography is the availability of fonts. Many professionally-produced offerings are expensive, and have licenses which are restrictive. Of course, there are some notable exceptions, with a number of excellent ‘free’ (as in speech) fonts available. Probably most notable to TeX users in the latter category are those from the Latin Modern/TeX Gyre Project.

Probably the biggest single player in pushing free font development is Google, but their focus is of course more on web technologies than typesetting. There’s now another notable entry in the open source font arena: Adobe. They have just released Source Sans Pro, which as you’ll guess from the name is a sanserif font. Currently, there are no small caps and no Greek or Cyrillic, but it does have old-style and table numerals, and superscript letters: check out the full coverage. (There’s no math support either, but we’ll let them off as that is seriously hard work.) The blog entry announcing the font suggests that there will be a matching monospaced variant in time.

As a demo of the new font, and to show off some TeX, Brent Longborough has put together a reproduction of the front page of Tschichold‘s Elementare Typographie using Source Sans Pro for XeLaTeX. This exploits the LaTeX3 coffins concept, and even takes accounts of side bearings using some code from TeX-sx. As the aim here is to show off the font, first we’ll see the result

then the code

% !TEX TS-program = XeLaTeX
\documentclass{article}
\usepackage[a4paper,margin=1pt]{geometry}
\usepackage{fontspec,xcoffins,xcolor,xparse}
\setsansfont{Source Sans Pro}
\pagestyle{empty}
\NewDocumentCommand{\kright}{m}{%
\leavevmode
#1%
\kern-\XeTeXglyphbounds3 %
\the\XeTeXcharglyph#1 %
}
\NewDocumentCommand{\kleft}{m}{%
\leavevmode
\kern-\XeTeXglyphbounds1 %
\the\XeTeXcharglyph#1 %
#1%
}
\pagestyle{empty}
\NewCoffin \result
\NewCoffin \aaa
\NewCoffin \bbb
\NewCoffin \ccc
\NewCoffin \ddd
\NewCoffin \eee
\NewCoffin \fff
\NewCoffin \rulei
\NewCoffin \ruleii
\NewCoffin \ruleiii
\begin{document}
\SetHorizontalCoffin \result {}
\SetHorizontalCoffin \aaa
{\fontsize{52}{50}\sffamily\bfseries \kleft{m}itteilunge\kright{n}}
\SetHorizontalCoffin \bbb
{\fontsize{52}{50}\sffamily\bfseries \kleft{t}ypographisch\kright{e}}
\SetHorizontalCoffin \ccc
{\fontsize{12}{10}\sffamily
\quad zeitschrift des bildungsverbandes der
deutschen buchdrucker leipzig
\textbullet{} oktoberheft 1925}
\SetHorizontalCoffin \ddd {\fontsize{28}{20}\sffamily sonderheft}
\SetVerticalCoffin \eee {180pt}
{\raggedleft\fontsize{31}{31}\sffamily\bfseries
elementare\\
typographie}
\SetVerticalCoffin \fff {140pt}
{\raggedright \fontsize{13}{14}\sffamily\bfseries
natan altman \\
otto baumberger \\
herbert mayer \\
max burchartz \\
el lissitzky \\
moln\'ar f.~farkas \\
johannes molzahn \\
kurt schwitters \\
mart stam \\
ivan tschichold}
% ------------------------------------------
\RotateCoffin \bbb {90}
\RotateCoffin \ccc {270}
% ------------------------------------------
\SetHorizontalCoffin \rulei  {\color{red}\rule{6.5in}{1pc}}
\SetHorizontalCoffin \ruleii {\color{red}\rule{1pc}{23.5cm}}
\SetHorizontalCoffin \ruleiii{\color{black}\rule{10pt}{152pt}}
% ------------------------------------------
\JoinCoffins \result                \aaa
\JoinCoffins \result[\aaa-t,\aaa-r] \rulei   [b,r](0pt,2mm)
\JoinCoffins \result[\aaa-b,\aaa-l] \bbb     [B,r](0pt,0pt)
\JoinCoffins \result[\bbb-t,\bbb-r] \ruleii  [t,r](-2mm,0pt)
\JoinCoffins \result[\aaa-B,\aaa-r] \ccc     [B,l](66pt,14pc)
\JoinCoffins \result[\bbb-l,\ccc-B] \fff     [t,r](-2mm,0pt)
\JoinCoffins \result[\fff-b,\fff-r] \ruleiii [b,l](2mm,0pt)
\JoinCoffins \result[\ccc-r,\fff-l] \eee     [B,r]
\JoinCoffins \result[\eee-T,\eee-r] \ddd     [B,r](0pt,4pc)
% ------------------------------------------
\noindent\TypesetCoffin \result
% ------------------------------------------
\end{document}


I think you’ll agree it’s a useful addition to the open source font library.

Filed under Uncategorized

## To the victor, the potatoes

2012-06-30 by . 0 comments

I remember when I wrote my first application. I was young and inexperienced – an unskilled programmer trying to learn the ways of the Force. The code – ah the code! – was a real mess. But hey, the application was up and running. And I was happy to make things work.

At some point, I got interested in opensource. It was way stronger than me. But how would I embrace the cause? I’m not a perfectionist, but I knew my code – at that moment – was bad, and I was afraid of being ridiculed because of it. Reluctantly, I took the first step and published my first code in the wild.

Get ready for the most random quote ever posted in our community blog. It’s from a Pokémon game: “You’re a rookie trainer, aren’t you? I can tell! That’s OK! Everyone is a rookie at some point!” Truer words were never spoken.

We only gain experience with time. Time helps us write better code. More than that: time helps us be better people.

No man is an island. Living in a very competitive world, we sometimes forget about our neighbour. The daily routine sometimes makes us close our eyes to others. We can’t let that happen to us. Helping other people in their journey – even a simple “good morning, have a nice day!” – frees us from the indifference and apathy of a typical cold-blooded human. And – believe me! – makes us better people.

The title for this blog post might be a little strange. It’s a famous passage from Quincas Borba, a novel by the Brazilian novelist Joaquim Maria Machado de Assis. Machado de Assis is surely amongst the great writers of all time. When I was a kid, we had to read at least one of his books for a literature class. And I picked that one. The full passage is as follows, a jewel of the Machadian literature:

Imagine a field of potatoes and two starving tribes. There are only enough potatoes to feed one of the tribes, who in that way will get the strength to cross the mountain and reach the other slope, where there are potatoes in abundance. But, if the two tribes peacefully divide up the potatoes from the field, they won’t derive sufficient nourishment and will die of starvation. Peace, in this case, is destruction; war is preservation. One of the tribes will exterminate the other and collect the spoils. This explains the joy of victory, anthems, cheers, public recompense, and all the other results of warlike action. If the nature of war were different, those demonstrations would never take place, for the real reason that man only commemorates and loves what he finds pleasant and advantageous, and for the reasonable motive that no person can canonize an action that actually destroys him. To the conquered, hate or compassion; to the victor, the potatoes.

In the novel, Quincas Borba is a philosopher who created a theory called Humanitism, which could be roughly summarized as the survival of the fittest. It’s a satire for both Comte’s Positivism and Darwin’s Natural Selection, a way of exposing the inhuman and unethical character of the survival of the fittest when applied to men.

I’ve been thinking of this question for a long time: should we share the potatoes? No.

We have something far more valuable to share than a mere potatoes: our knowledge. Sharing what we know gives everybody the chance of surviving. A community built with knowledge and valuing everyone in particular is healthier than a bunch of crumbs.

It’s been a privilege to be part of our TeX community. Everybody is welcome. And we try our best to make people feel that way. From a TeX newbie to an experienced TeXnician, everybody can help, either asking or answering questions. My great friend egreg brilliantly said that “without problems to solve the knowledge doesn’t improve”.

If you have any questions, please ask! Don’t be afraid. And if you can contribute to a question, either by answering it or even adding a comment, please do it. Everybody benefits from our actions, especially our community.

Help us make our community even better. Ask questions, write comments and answers, give advices, upload packages to CTAN, fork repositories, join a project, chat with other members. To the victor, the potatoes. To the wise, the community.

Filed under Advocacy, TeX.sx