Call Windows Support

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg
Showing posts with label LaTeX. Show all posts
Showing posts with label LaTeX. Show all posts

Tuesday, 15 October 2013

PythonTeX

Posted on 14:33 by Unknown
I write technical documents in LaTeX, and my programming language of choice is (currently) Python.  I’m about to start writing a large LaTeX document that will have lots of figures drawn with Python’s matplotlib.  So, I was wondering, wouldn’t it be nice if there was some support for including these more directly in the document.  I went surfing, and came across PythonTeX, by Geoffrey M. Poore.

PythonTeX doesn’t just allow you to put figures in your LaTeX, it allows whole chunks of Python, with the results embedded in the output.  After watching a YouTube video on the capabilities, I thought it looked interesting, so I decide to give it a go: it might well be useful, and anyway it’s a great displacement activity from actually starting writing that document.

It wasn’t a particularly onerous installation process, as LaTeX and Python installations go.  In order to get the test document, pythontex_gallery.tex, to format properly, I just had to:
  1. download PythonTeX
  2. run LaTeX on the provided example file pythontex_gallery.tex (I use TeXnicCenter)
  3. give LaTeX permission install several macro packages (as warned by the PythonTeX installation documentation)
  4. from the command line, run pythontex.py pythontex_gallery.tex
  5. scrutinise the error messages to see I needed pygments.style, sympy, and scipy  (again, as warned by the PythonTeX installation documentation)
  6. go to the pygments page, and see that it recommends installation via ez_setup
  7. go to the ez_setup page, and download it
  8. from the command line, run python ez_setup.py
  9. download the relevant pygments “egg”
  10. from the command line, run easy_install Pygments-1.6-py2.7.egg
  11. download and install sympy
  12. download and install scipy (hence discovering that it is pronounced “sigh pie”, not “skippy”)
  13. from the command line, run pythontex.py pythontex_gallery.tex
  14. run LaTeX on pythontex_gallery.tex again
At this point out popped a LaTeX pdf with figures, equations, integrals, and expression derivations all produced from the embedded python!

Now that I have everything installed, all I have to do to generate this pdf from scratch is:
  1. run LaTeX on pythontex_gallery.tex
  2. from the command line, run pythontex.py pythontex_gallery.tex
  3. run LaTeX on pythontex_gallery.tex again
Simples!

There is also a handy utility to convert the LaTeX file with embedded python into a stand-alone LaTeX document, suitable for other people to process.  (This is essential if the document needs to be sent off for publication, for example.)
  1. edit the LaTeX file to include the depythontex=true option in the pythontex package
  2. run LaTeX on pythontex_gallery.tex again
  3. run pythontex.py pythontex_gallery.tex again
  4. run depythontex.py --graphicspath pythontex_gallery.tex final.tex
Then anyone can run LaTeX on final.tex without needing PythonTeX.

Having installed PythonTeX, and checked that it can at least process the supplied test file, I next needed to check that I can get it to produce the kind of diagrams I want.

So I wrote a short LaTeX document with the body:
\begin{pylabcode}
n = 16
m = 6
figure(figsize=(n*0.2, m*0.2))
gca().axison = False
x = 8
y = 4
fill( (x,x+1,x+1,x), (y,y,y+1,y+1), 'r', linewidth=0)
for i in range(0,n+1):
ii = (i,i)
jj = (0,m)
plot(ii,jj,'0.4', linewidth=0.2)
for j in range(0,m+1):
ii = (0,n)
jj = (j,j)
plot(ii,jj,'0.4', linewidth=0.2)
savefig('myplot.pdf', bbox_inches='tight')
\end{pylabcode}

\includegraphics{myplot.pdf}

This is a \pylab{'${0} \\times {1} = {2}$'.format(n, m, n * m)}
square grid, with a red block at $(\pylab{x},\pylab{y})$.

The top bit is some python code to draw a grid and a red square, and the bottom bit is some explanatory LaTeX text.  Going through the LaTeX-PythonTex-LaTeX process gives:
Excellent.  I can use it to draw diagrams in situ.  The great advantage this approach has is that I can keep all my code for the figures in the same file as the LaTeX text, so there will be much less chance for fragments to wander off and get lost.

As shown in the code above, the LaTeX can include references to python variables, which is how the caption part is generated.  Then, if I decide that I want a slightly different figure, I just edit this single file, change only the values assigned to n,m,x,y in the python part, and get something like:

The new variable values have changed the drawn figure, and these changes have also been propagated to the caption, including the calculation of the product.  This gives a much more sophisticated form of cross referencing.

I’m sold!


Read More
Posted in LaTeX, python | No comments

Sunday, 4 August 2013

a new piling system

Posted on 04:15 by Unknown
I write academic papers, and read a lot of other papers. What with hard copy scattered through filing cabinets, and soft copies on a wide variety of websites, it can be hard to keep track of what I’ve read, made notes on, made BiBTeX citation data, and referenced.

Nearly two years ago I had a go at using Mendeley, designed to help with this very task. But for some reason, it never gelled for me, and I gave up using it. Then, when I became an Evernote convert, I fiddled about with using it to store data on the papers: author, title, etc, notes, BibTeX, and links to the papers themselves. But it was clunky work-flow, requiring a lot of hand-effort. Only the note keeping part of it worked well.

Then a colleague raved about Paperpile on his G+ stream. I had a look. It has a similar concept to Mendeley and other such systems, keeping references, supporting tags, good searching, associated notes, and citation output in multiple formats (although I only care about BibTeX). Instead of being a stand-alone application, however, it’s Chrome-based, and uses your Google Drive as a repository to store your papers. It’s currently in Beta, and I thought I’d give it a try. I emailed off for an account, and about a week later I got one.

The first thing I did was import my dusty Mendeley data (with a single button click and a log on), so I started off with a well-populated, if slightly out-of-date, database. I decided to trial it on the paper I had just started writing.

I defined a tag for the new paper. As I was writing, each time I included a reference in the text, I checked if that reference was already in my Paperpile database; if not, I added it. (Since there is usually a fair amount of overlap between bibliographies of papers in a similar domain, this should get faster as the db gets more populated.) Then I tagged it with the paper’s tag, and any other relevant tags.

My current Paperpile db, with 321 entries

To generate the BibTeX, all I needed to do was select the tag, which selected all the references, and then export the whole BibTeX file in one go.

The real benefit showed up when I got comments back on a draft of the paper. One was about a short quotation I had included, and I needed to find the quotation in its original context in order to address the comment. Click the Paperpile tab in Chrome. Type the author’s name into the search box; the paper’s details appear. Click the “view PDF” button. Voila! The paper is on my screen! I can’t think of a faster way to achieve that, without using telepathy.

You can upload in various ways, including PubMed, arXiv, doi, navigating to a website, or just giving it a PDF.  When you upload a PDF directly, the system searches the web to find the right data to populated the various fields. It gets this mostly right, but there have been a couple of odd peculiarities. Still, the system is in Beta. I reported the couple of weird results, and got very fast and helpful responses from the team. (I like Beta testing. I can whinge about software, and feel virtuous about doing so!)

One thing I particularly like is that the uploaded PDFs are stored in my Google Drive in a very sensible way. The files have obvious names: <Author> <Year> - <Title>.pdf. So if Paperpile were to disappear for any reason, I still have all my PDFs in a very usable form. (I’m not expecting it to disappear; I’m just paranoid: I have my Google Drive synched to my hard drive at home, in case Google disappears!)

I haven’t used all the facilities, in particular, I haven’t exploited the Google Docs integration. The Paperpile team report that some people are using it to write their papers collaboratively in Google Docs. That looks potentially useful, but I don’t use this plain format: I write my papers in LaTeX/BibTeX, using TeXnicCenter.

One part of the system I probably won’t use that much is the notes field. It’s perfectly fine, but I like to keep more substantial notes, with formatting, sketches, figures, and the like. So I’ll continue using my Evernote “papers” notebook, but now just for the notes, not the entire paper and other detials. For a paper with notes, I add a link from the Paperile entry to the relevant Evernote note, using the URL field which gives a clickable link (and I add an Evernote tag, to make it clear to me that there is a note). Similarly, I have a lot of already existing book reviews on my website. So when I include a book that I own, I add a link to the review on my site.

In fact, I think that having a variety of tools that each does their own thing well, with links between the relevant parts, works better than trying to shoehorn all capability into every application. So in Evernote, for example, for a meeting note, I don’t copy the agenda from the email notification, I just store a link to it. Evernote Webclipper allows you to clip the whole email into Evernote, but that just seems to cause unnecessary duplication. It’s good practice to keep only one copy of data (except for backups, of course!), otherwise there is the potential for copies to get out of synch. When that agenda is inevitably later updated, and a new copy emailed out, I don’t have to do anything: provided it is sent out with the same subject line, the Gmail link pulls up the entire conversation, and I can select the most recent agenda. (One day, the agenda setters may start using Google Docs, and so everyone will always have the most up to date version – provided they haven't clipped it into Evernote!) With all these web-based tools, the URL can link everything together.

In summary: first impressions of Paperpile are very favourable. I’ve successfully and productively used it for writing a paper, and it being web/Google based means it’s available at work, at home, and elsewhere, without me having to do anything special. I’ll report on progress if and when it gets more deeply integrated into my web-life.

Read More
Posted in Evernote, LaTeX, publishing, research, science, web | No comments

Wednesday, 27 March 2013

hunt the LaTeX symbol no more

Posted on 13:53 by Unknown
So there you are, writing some maths in LaTeX, and you need that symbol that's a tilde on top of an equals sign:
but you can't remember the markup.  So, it's off to Google: "LaTeX mathematical symbols".  Up pops "The Comprehensive LaTeX Symbol List", a 178 page PDF.  Scan through section 3, "mathematical sysmbols", and eventually find:


Squint at the screen.  Zoom in.  Yes, it's \cong.  Carry on typing.  Then you need another symbol...

Surely there's an easier way?  Well, I've just stumbled across a marvellous website that gets rid of the need to scan through hundered of pages of tiny symbols.  Meet Detexify - LaTeX symbol classifier:


Do what it says -- draw here!



It takes a few seconds, but then a bunch of symbols appears -- including \cong. Perfect!

My symbol drawing is dreadful here, because I'm using a mouse, and using it right-handed at that.  But that doesn't matter, because the system is very forgiving and provides a range of possibilities "similar" to the crude sketch:




If you know what it looks like, you can find it.

Brilliant.
Read More
Posted in LaTeX | No comments

Sunday, 24 March 2013

the rise and fall of Ctrl-S

Posted on 14:35 by Unknown
I first used a computer back in the late 1970s, when I was an undergraduate physics student. In those days, we wrote programs on punched cards. To lose your program, you had to lose the cards (or, actually, just shuffle them).  To prove we never throw anything away, here is a program from the 1970s:

a program statement from yesteryear: 12  MAG(J,K) = 0
a whole program; no idea what it does
By the time I was a research student, punched cards had given way to text editors through VT100 terminal sessions.  I wrote my thesis in troff (one of my fellow students was writing his in this new-fangled thing called TeX), using the ZED line editor.  In order to save your changes, you had to exit the editor, save, and restart the editor, a non-trivial sequence of operations that interrupted the writing flow.  However, by the time I was writing up, the IBM 370 mainframe was on its last legs, about to be replaced by a new IBM 3081, and crashing frequently.  So I got in the habit of exiting the editor every 5-10 minutes, saving, and re-entering.

Frequent saving was ingrained in my workflow by the time applications came uniformly equipped with Ctrl-S.  (Saving without exiting.  Luxury!)  Every time I would pause to think what to write next, in word processor, spreadsheet, or text editor, I would automatically hit Ctrl-S.  It's now an automatic behaviour.

But modern applications no longer use Ctrl-S.  They just continually save, automatically. There's no need to keep saving explicitly.  Most applications that have an auto-save feature also let you do your own saves in between.  But some applications no longer have a user save command at all.  I noticed this first with Evernote, and then with Google Docs.

Fortunately, these applications haven't mapped Ctrl-S to any other function (mail programs where Ctrl-S means "send" are a real nightmare), so nothing bad happens if I do reflexively hit Ctrl-S.  Which I do sometimes, because it feels really weird not to keep saving after all these years.

Three generations of saving technology: manual-slow-and-clunky, manual-easy, automatic. That's probably progress.


Read More
Posted in computer, history, LaTeX | No comments

Thursday, 27 December 2012

ODE to a Petri net

Posted on 06:29 by Unknown
Writing ordinary differential equations (ODEs) to model various natural world processes comes more readily to some than to others.  And once written, it can take some effort to pick apart their real-world meaning.  It would be nice to have a more visual form.  Petri nets are one such approach.

Epidemics


For example, consider the simple SIR model of epidemic infection.
  • +++S+++ : those uninfected, but susceptible -- their number is reduced as they become infected, at a rate proportional to the number of susceptibles and the number of infected
  • +++I+++ : those infected -- their number is increased by susceptibles who become infected;  it is also reduced as those infected recover, at a rate proportional to the number of infected
  • +++R+++ : those recovered -- their number is increased by those who were infected recovering
For those happy with ODEs, it is straightforward to write down a set of coupled equations to model this:
$$\dot{S} = - i S I $$
$$\dot{I} = i S I - r I$$
$$\dot{R} = r I$$
In addition to natural language (the bullet list) and maths (the ODEs), there is another language useful to explain and understand models: diagrams.

For example, we could draw a simple state transition diagram to show the movement from susceptible to infected to recovered:

This captures some of the information, but not all of it.  A (continuous) Petri net can do better:


The circles are called "places", and represent the "things" involved: here the susceptibles, the infected, and the recovered.  The rectangles (the colours aren't significant) are called "transitions", and represent how the things in "input" places get transformed into things in "output" places.
  • transition +++r+++: an infected comes in, and a recovered comes out
  • transition +++i+++: a susceptible and an infected come in; two infected come out (the two infected outputs are the newly infected, and the original infecter)
This diagram has enough information in it to reproduce the original ODEs.  We have one ODE per place, with the terms being given by the transitions feeding that place.
  • place +++R+++. +++R+++ has only one transition feeding it: transition +++r+++.  It is feeding into +++R+++ at a rate proportional to all the inputs to +++r+++: here just +++I+++.  Hence +++\dot{R} \propto I+++.  If we call the constant of proportionality (the rate constant) +++r+++, we get +++\dot{R} = r I+++
  • place +++S+++. +++S+++ has only one transition, +++i+++, removing stuff from +++S+++.  It is removing at a rate proportional to all the inputs to +++i+++: here +++S+++ and +++I+++.  Calling the rate constant +++i+++, we get  +++\dot{S} = - i S I+++ (the minus sign is there because we a removing from +++S+++, and it is conventional to keep the rate constants positive)
  • place +++I+++.  +++I+++ has two transitions: +++i+++ both feeding it (two input arrows) and removing from it (one output arrow), and +++r+++ removing from it.  We get +++\dot{I} = i S I - r I+++
Thus we have recovered the original equations.

We can write this focussing on the transitions, in a more algorithmic way (algorithms, or pseudo-code, are yet a further language we can use to explain, describe, and define processes).
  • initialise the rates of change to each place to be +++0+++.  +++\dot{S}, \dot{I}, \dot{R} := 0+++
  • transition +++r+++.  This is removing stuff from place +++I+++ and adding it to +++R+++ at a rate +++rI+++. Update the output place +++R+++ and input place +++I+++ appropriately: +++\dot{I} {-}{=}\ rI+++, +++\dot{R} {+}{=}\ rI+++
  • transition +++i+++.  This is removing stuff from place +++I+++ and from place +++S+++ at a rate +++iSI+++ and adding it to +++I+++ at a rate +++2iSI+++ (from the two input arrows).  Hence there is a net input to place +++I+++ at a rate +++iSI+++.  Update the output place +++S+++ and net input place +++I+++ appropriately: +++\dot{I} {+}{=}\ iSI+++, +++\dot{S} {-}{=}\ iSI+++
We can write this as a general algorithm:
  for each place Pi
Pi_dot := 0
for each transition Ti
let Pin = < Pin_1, ... , Pin_n > = list of n places,
one for each input arrow of Ti;
Pout = list of m places, one for each output arrow of Ti;
t = Ti x Pin_1 x ... x Pin_n
for each Pi in Pin
Pi_dot -= t
for each Pi in Pout
Pi_dot += t
So now we have a diagrammatic form, and an ODE form, that are equivalent, and an algorithm to translate on to the other.  This is useful, because we can use them interchangeably, without risk of losing information.  In particular, notice how explanation accompanying the Petri net focusses on what is happening in the transitions, whilst that for the ODE form focusses on what is happening to the places.  Having different forms of explanation can be useful in different circumstances (modelling, communication, modification, validation, calculation, etc).

Catalysis


Although that all works well, the handling of the infecter in the +++i+++ transition seems a bit unnatural: infecter goes in, infecter comes out, resulting in an addition and subtraction of this rate.  The infecter is needed for the transition, and affects the rate of the transition, but is not itself changed by the transition.  In chemistry, this is called a catalyst, and there is some special Petri net syntax for it.  We can draw the SIR Petri net above equivalently as:


Here the dashed arrow means that +++I+++ is a catalyst: it is needed for the transition, but is not consumed by the transition. Hence there is now only one arrow out to +++I+++: since the catalyst wasn't consumed, it doesn't need to be replaced; the remaining single arrow represents the newly infected.

The algorithm needs a little  modification:
  for each place Pi
Pi_dot := 0
for each transition Ti
let Pin = < Pin_1, ... , Pin_n > = list of n places,
one for each input arrow of Ti;
Pcat (sublist of Pin) = list of catalytic input arrow of Ti;
Pout = list of m places, one for each output arrow of Ti
let t = Ti x Pin_1 x ... x Pin_n
for each Pi in Pin \ Pcat
Pi_dot -= t
for each Pi in Pout
Pi_dot += t
So the catalytic arrows still contribute to the functional form of the overall rate +++t+++, but not to the changes to the specific places.

Logistic equation


Possibly the simplest bounded growth model in biology is the logistic equation:
$$ \dot{N} = rN(1-N/K)$$where +++r+++ is the growth rate, and +++K+++ is the carrying capacity (so when +++K=N+++, +++\dot{N}=0+++).

This can be drawn as an equivalent Petri net:


  • transition +++r+++ (birth): one in, two out
  • transition +++rK+++ (competition): two in, one out
These two transitions can also be shown in a simpler catalytic form (if maybe not with the same intuition as before):

  • transition +++r+++ (birth): one "catalyses" the birth of the other
  • transition +++rK+++ (competition): one "catalyses" the death of the other

Lotka-Volterra predator-prey


The simple predator-prey model, usually cast as rabbits and foxes, has rabbits being born, predated on by foxes to produce more foxes, who then die.  A simplistic version of this might be:


  • transition +++b+++ (birth): one rabbit in, two rabbits out
  • transition +++d+++ (death): one fox dies
  • transition +++p+++ (predation): one fox and one rabbit in, two foxes out
This however has a problem: it has a new fox produced every time a rabbit is eaten.  Real foxes need more food than this to reproduce.  We can't solve the problem by changing the rate +++p+++, as this affects the consumption of rabbits and production of foxes equally.  What we really need is for the consumption of a rabbit to produce a bit of a fox.  We can do this by adding a separate rate to the arrow:


  • transition +++p+++ (predation): one fox and one rabbit in, one plus +++\epsilon+++ foxes out
The algorithm needs to be updated to multiply the rate by the weight of the arrow before adding/subtracting  as appropriate.  This then yields the familiar equations:

$$\dot{R} = R(b-pF)$$
$$\dot{F} = F(-d+p\epsilon R)$$

If we use the catalytic form, the diagram simplifies to:


  • transition +++p+++ (predation): one fox "catalyses" the transformation of a rabbit into +++\epsilon+++ of a new fox

Lotka-Volterra competition


The simple competition model, usually cast as rabbits and sheep, has rabbits and sheep being born and dying following their own logistic equation, and also competing with each other for resources.


  • transition +++rb,rs+++ (birth): one +++x+++ "catalyses" the birth of the next +++x+++
  • transition +++rc,sc+++ (competition): one +++x+++ "catalyses" the death of another +++x+++
  • transition +++rs+++ (rabbit/sheep competition): one sheep and one rabbit in, a proportion of each out
$$\dot{R} = R(rb-rcS) + (pr-1)rs RS$$
$$\dot{S} = S(sb-scS) + (ps-1)rs RS$$

Combining predator-prey and competition


The competition example has two logistic "subnets", showing how these diagrammatic forms can be readily combined.  So, for example, we could easily add some foxes to the brew:


$$\dot{S} = S(sb-scS) + (ps-1)rs RS$$
$$\dot{R} = R(rb-rcS) + (pr-1)rs RS -pRF$$
$$\dot{F} = F(-d+p\epsilon R)$$

If the foxes also worried the sheep, the diagram would get messier, but would still visually represent the relationships between the different components.

Diagrams v cartoons


Pictures can be very helpful at getting across ideas, but they have their problems if they are ambiguous, incomplete, or otherwise open to misinterpretation.

The (continuous) Petri nets shown here have a formal meaning: they can be translated into equivalent ODEs. They are not informal "cartoons", merely sketching some part of the meaning.  There is an algorithm from diagrams to equations, and it is possible to build a tools allowing the manipulation of diagrams and equations as two different "concrete syntaxes" of the same underlying model.  Which syntax to use depends on what you are doing: it truly is the best of both worlds.

Acknowledgments

  • I first came across the formal link between continuous Petri nets and ODEs on Alexi Sharov's web site
  • I was reminded of using Petri nets to model population dynamics on reading David Tanzer's guest post on the Azimuth site
  • I drew the diagrams in graphviz
  • The maths is formatted with LaTeX and displayed using MathJax
Read More
Posted in algorithm, LaTeX, mathematics, science | No comments

Sunday, 16 September 2012

le banana split

Posted on 04:58 by Unknown
On my recent trip to France, a particular menu item, in a menu entirely in French, was “Le banana split”. This caused great hilarity among the Brits present. We also quizzed out French colleagues, “why ‘le’”? They professed ignorance, particularly due to the fact that it is, au contraire, “la banane”. Is it that all foreign introductions are assigned masculine gender? They didn’t know.

This then segued off into a discussion of gendered languages, with the French asking the Brits, “so, if you were to give the sun, or a table, a gender, what would it be?” and the Brits responding with baffled incomprehension. The question makes about as much sense as, or possibly even less sense than, the party game “if you were a piece of furniture, what would you be?”

Another aspect of the discussion caught my attention. The menu item is pronounced by the French something like (to my English-tuned ears) /lʊ  bæ'næ'næ  spliːt/ (“le ban-ann-ah spleet” *): all three “a”s the same, and a long “i”. In contrast, banana in (my dialect of) English is pronounced /bə'nɑːnə/ (“buh-nah-nuh”) , or even /bə'nɑːnəː/ (“buh-nah-ner”), with three different pronunciations of “a”.

And that led me to recall the peculiar sentence (there are different variants of it, but this is the one I know):
The thoughtful rough-necked dough-faced ploughman strode, coughing and hiccoughing, through the streets of Scarborough. 
If you are a native English speaker, you will have read that with no trouble (except, possibly, for hiccough). If not, you may possibly have groaned at the eight oughs there, each with a different pronunciation. Let’s enumerate them:
  1. ough can be pronounced /ɔː/ (“awe”); thought is pronounced /θɔːt/. Other words ending in /ɔːt/ include aught, bought, brought, caught, court, daughter, fraught, fort, fought, haughty, naught, nought, nautical, ought, port, quart, snort, sort, sought, taught, taut, tort, wart, and wrought.
  2. ough can be pronounced /ʌf/ (“uff”); rough is pronounced /rʌf/. Other words ending in /ʌf/ include bluff, buff, chough, cuff, duff, fluff, gruff, huff, muff, enough, puff, ruff, scuff, slough, stuff, and tough.
  3. ough can be pronounced /əʊ/ (“oh”); dough is pronounced /dəʊ/. Other words ending in /əʊ/ include blow, bow, crow, doe, foe, Flo, flow, go, glow, grow, hoe, Joe, low, mow, no, oh, roe, row, sew, show, sloe, slow, snow, so, though, throw, toe, and tow.
  4. ough can be pronounced /aʊ/ (“ow”); plough is pronounced /plaʊ/. Other words ending in /aʊ/ include bough, bow, brow, cow, dhow, how, now, ow, pow, prow, proud, row, scowl, Slough (the place), sow, tao, vow, and wow.   And drought has the same ough sound.
  5. ough can be pronounced /ɒf/ (“off”); cough is pronounced /kɒf/. Other words with /ɒf/ include coffee, doff, off, quaff, slough, soft, toffee, trough, and waft.
  6. ough can, in one word only, be pronounced /ʌp/ (“up”); hiccough is pronounced /'hɪkʌp/. Other word ending in /ʌp/ include the much more prosaic cup, pup, sup, up. Hiccough is a somewhat archaic spelling, and is more likely to be written hiccup today. 
  7. ough can be pronounced /uː/ (“oo”); through is pronounced /θruː/. Other words ending in /uː/ include blew, blue, boo, chew, clue, coo, do, due, dew, flew, flu, flue, goo, grew, grue, hew, Hugh, Jew, lieu, loo, moo, new, poo, queue, (kanga)roo, rue, shoe, shoo, shrew, slew, slough, sue, too, threw, true, view, who, woo, zoo 
  8. ough can be pronounced /ə/ (“uh”), the unstressed schwa sound; Scarborough is pronounced /'skɑːbərə/, or even /'skɑːbrə/. Other words ending in /ə/ are legion, and include anger, author, cellar, colour, comma, sofa, thorough. 
Presumably the strode is in there to try to trick you into writing something like stroughed. And why not?

Then there is the town of Loughborough, with two ough occurrences, each pronounced differently: /'lʌfb(ə)rə/ (“Luff-bruh”). Variant pronunciations don’t end with ough, of course. The examples above show that each vowel sound has several possible spellings; in particular, both bow and sow can be pronounced to rhyme with either plough or with dough. The other way round, slough must hold the record, with the same word having three different meanings, each with its own different pronunciation of ough: /slʌf/ (“sluff”, to shed), /sluː/ (“slew”, a swamp), and /slaʊ/ (the town of Slough, and, confusingly, the Slough of Despond, or swamp of despair).

Why? Why so many vowel sounds with the same spelling? And why such a weird spelling at that? Well, it’s actually one vowel sound and following consonant, that has meandered off in many directions over the years. The clue is in yet another pronunciation of ough, as /ɒx/. That’s a sound that is no longer in English, except in the word loch (as in Loch Ness), also spelled lough for Irish lakes, for example Lough Neagh, and some lakes in the north of England. Even this sound is fading, as many people pronounce loch as /lɒk/ “lock”. Computer scientists will also know this /x/ sound, as the final sound in Knuth’s TeX (but not necessarily LaTeX).

More detail (as ever) on ough can be found on wikipedia.

This disappearance of original sounds explains some (but by no means all!) of the weirdness of English spelling. Take, for example, bright, light and night, pronounced /brʌɪt/ (“brite”) /lʌɪt/ (“lite”), and /nʌɪt/ (“nite”) respectively. Aargh! It’s that silent gh again! And for the same reason: it did used to be pronounced. It is still be heard in some Scots dialets.  Consider:
It's a braw bricht moonlicht nicht the nicht.
(It’s a grand bright moonlit night tonight.)
Here the gh, morphed to ch, can still be heard, pronounced /x/.

At the front end of some English words is that other weird silent letter, k, as in knife (/nʌɪf/, “nife”), knee (/niː/, “nee”), and, just to combine the pain, knight (/nʌɪt/, “nite”). As you can guess, the k was originally pronounced. These words all derive from Old English words beginning cn. But that’s also not a sound that has survived into modern English. Where the initial k is still pronounced, the English form has added a vowel: good old King Canute of wave fame is actually Cnut.

So, knight was once probably pronounced something like /knɪxt/ (“k-nicht”); now we’re (somewhat) in Monty Python territory, and back to French!

And after writing this, I was so thoroughly fraught that I thought I’d forgotten how to spell. If I just tough it out, though, I’ll get through it.


------
* pronunciations like /kʌp/ are written using the International Phonetic Alphabet (IPA), as given by the online Oxford Dictionaries.  I also append my attempt at transliterating these (“cup”), but this is, of course, ambiguous, precisely because English spelling is not phonetic. 

The IPA is explained on wikipedia, including some variant transcriptions.

Read More
Posted in language, LaTeX | No comments

Sunday, 13 November 2011

On the Road to Mendeley

Posted on 12:49 by Unknown
I decided to evaluate Mendeley as a means to "organise" my scientific paper reading and note-taking. A hard disk full of PDFs from forgotten sources, with separate BibTeX files for each paper I write, is messy.

I decided on Mendeley after reading a few reviews. These mostly said good things, and only very few bad things. The desktop application lets you keep the PDFs of your collected papers (and other materials) together, along with notes, tags, and bibliographic information.

You can search on authors, keywords, tags, text, and so on.

You can keep papers in separate directories.  Having recently started using Gmail, and got the hang of using tags instead of directories to classify my emails, I was pleased to see tags also supported here. I will be tagging papers not only with the bits of their content of interest to me, but also to tell me which of my own papers have referenced them.

You can export reference information in BibTeX format, for ease of writing papers. (Apparently you can also export in MS-Word formats; but why would you write a scientific paper in anything other than LaTeX?)

So I spent a happy few hours importing my PDFs, and various BibTeX files, merging duplicates, cleaning up the entries, and generally populating my account:


You don't have to have a PDF of every paper: you can store just the bibliographic details, or a URL to where it is stored elsewhere.  But if you want to annotate the PDF, you need your own local copy.  (There is a separate "notes" field, so you don't need to do this unless you want to annotate in the exact place.)  You can sync all this information across multiple computers. (I haven't tried this yet: I've only accessed it from home so far). I can see that free 500MB isn't going to go very far...

I'll try using it for a while, and in anger while writing my next paper, to organise the bibliographic information.  So far it looks very useful.  It's the kind of thing that will make writing a review paper a lot easier, I suspect.
Read More
Posted in LaTeX, science, web | No comments

Sunday, 6 March 2011

Packing in the text

Posted on 05:02 by Unknown
I write many documents in LaTeX, and it is great for things like bibliographies, cross-referencing, and defining styles. But the default styles, such as 'article', are a bit wasteful of space. For example
\documentclass[a4paper]{article}
\title{Your Title Here}
\date{}

\begin{document}
\maketitle
\begin{abstract}
Lorem ipsum ...
\end{abstract}
\section*{Introduction}
...
\end{document}
gives the page shown on the right.

This is particularly a problem if you are preparing a document with strict page limits, such as a research proposal or a conference paper. Those places often put their own style requirements. Some provide a LaTeX style file, which is fine (provide the style actually works!), but others are a little less helpful.

Here is a typical requirement:
Font size 11 is the minimum font that is acceptable, and the minimum margin in all directions is 2cm. For accessibility purposes, a sans-serif font style such as Arial or Helvetica should be used as these are more easily readable to those with visual impairment. For the same reason, type should be justified only on the left hand side.
How do we get LaTeX to meet these requirements? Well, there are a few useful packages. 'geometry.sty' lets the margins be easily set. So we can get a conformant document with:
\documentclass[a4paper,11pt]{article} % 11pt font
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry} %min margins

\renewcommand{\sfdefault}{cmss} % sans serif
\renewcommand{\familydefault}{\sfdefault} % for whole doc

\raggedright % left justified
\parindent 1em % because \raggedright stops indenting

\begin{document}
...as above
\end{document}

Not only is it conformant, it also has more text on it than the plain `article' version. But we can do better. One reason the article style is so fascistic about its left and right margins (try to get more text by dropping a point size, and it reduces the line length!) is that very long lines are hard to read: you lose your place as you track back at the end of a line. A "11pt text, 2cm margin" format results in lines too long to read comfortably. So let's do what the newspapers do, and go to multi (here, two) columns. This actually saves space, as short section titles no longer take up a whole full width line.

Also, let's take the title and abstract into the main body, and tighten up the space around section headings using the 'titlesec.sty' package. Finally, use some 'negative leading' to get the lines a little closer together (without looking cramped), and we get:
\documentclass[a4paper,twocolumn,11pt]{article}
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}

\renewcommand{\sfdefault}{cmss}
\renewcommand{\familydefault}{\sfdefault}
\raggedright
\parindent 1em

\usepackage[small,compact]{titlesec} % section headings in smaller font size, less whitespace
\renewcommand{\baselinestretch}{0.9} % closer lines
\begin{document}
\section*{\Large Your Title Here}
\section*{Executive summary}
Lorem ipsum ...
\section*{Introduction}
...
\end{document}
The result has about twice as much text as the original 'article' style, and is fully conformant to the stated requirements.

The 'titlesec' package also allows some fancier formatting of section headers (for example, when things get a little squashed, I like to put a rule over major section titles, to aid the eye), but that's another story.
Read More
Posted in LaTeX | No comments

Saturday, 22 January 2011

PDF diagrams in LaTeX

Posted on 13:59 by Unknown
Convert postscript to pdf using

$ epstopdf .[e]ps
$ ls *.pdf
.pdf
include in LaTeX file:

\usepackage[pdftex]{graphics}

\begin{figure}
\begin{center}
\scalebox{0.8}{\includegraphics{}}
\caption{....}
\label{fig-...}
\end{center}
\end{figure}
Read More
Posted in grimoire, LaTeX | No comments
Older Posts Home
Subscribe to: Posts (Atom)

Popular Posts

  • hyperbolic hyperbole
    What's with hyperbolic discounting? It's everywhere ! I first consciously noticed the term at a workshop about six weeks ago, and n...
  • better use seaweed
    As Neils Bohr is alleged to have said , “prediction is very difficult, especially about the future”. My smartphone has a weather app on it t...
  • oh dear
    We have a garden pond to help encourage frogs and other amphibians. Hedgehogs may suffer, however. :-(
  • "Windows support" -- not
    Just had another scam phone call -- someone with a strong Indian accent claiming to be calling from "Windows Technical Support" (o...
  • national stereotypes
    I've just got back from a very productive three day meeting in Paris. Just around the corner from where I was working, there was a marv...
  • retrospective holiday diary day 1: travelling north
    We went to the Lake District last “summer” ; this “summer” it was time for touring the other side of the country: Northumbria. The holiday s...
  • retrospective holiday diary day 5: trains
    Monday 24 September, and the long-threatened rain finally arrived. So this was the ideal day for the planned Carlisle-Settle rail trip . Bu...
  • funfair mirror trees
    One of the trees in our garden has died.  It died last summer in the drought, but we gave it a year to prove to us it really was dead.  It i...
  • retrospective holiday diary day 3: Lindisfarne
    Saturday 22 September, and the weather was still fine, sunny holiday weather so we decided to take advantage of the sunshine, and do Lindisf...
  • more scammers
    So not long after the scam phone call , the phone rings again. It's British Gas -- they get to call me because I'm actually a custo...

Categories

  • 3D printer
  • algorithm
  • astronomy
  • birds
  • Bonnie Tyler
  • books
  • cognition
  • computer
  • conference
  • Doctor Who
  • driving
  • ducks
  • duodecimal
  • education
  • electricity
  • estimation
  • Evernote
  • evolution
  • font
  • food
  • fractals
  • game
  • garden
  • graphics
  • grimoire
  • history
  • holiday
  • humour
  • language
  • LaTeX
  • lego
  • lol
  • mathematics
  • medicine
  • money
  • music
  • obituary
  • pedantry
  • politics
  • probability
  • psychology
  • publishing
  • python
  • quotations
  • research
  • robots
  • science
  • science fiction
  • space flight
  • statistics
  • TPS
  • trains
  • tree
  • TV
  • weather
  • web

Blog Archive

  • ▼  2013 (119)
    • ▼  December (1)
      • that's not in the least bit suspicious
    • ►  November (17)
    • ►  October (12)
    • ►  September (10)
    • ►  August (9)
    • ►  July (8)
    • ►  June (10)
    • ►  May (19)
    • ►  April (10)
    • ►  March (9)
    • ►  February (4)
    • ►  January (10)
  • ►  2012 (103)
    • ►  December (16)
    • ►  November (8)
    • ►  October (14)
    • ►  September (6)
    • ►  August (13)
    • ►  July (8)
    • ►  June (6)
    • ►  May (9)
    • ►  April (10)
    • ►  March (7)
    • ►  February (5)
    • ►  January (1)
  • ►  2011 (79)
    • ►  December (7)
    • ►  November (5)
    • ►  October (10)
    • ►  September (7)
    • ►  August (6)
    • ►  July (5)
    • ►  June (6)
    • ►  May (6)
    • ►  April (9)
    • ►  March (9)
    • ►  February (3)
    • ►  January (6)
Powered by Blogger.

About Me

Unknown
View my complete profile