Live data from Hacker News

Tips and tricks to write LaTeX papers in with figures generated in Python

github.com

21–30 of 68 posts

Re: Tips and tricks to write LaTeX papers in with figures generated in Python

#21

I also recommend separating repetitive parts of plot generating code into template files, such as with mako or jinja2, and then programmatically generate sequences of plots by first piping the data into the jinja2 template, and then using insert commands to insert it into a bigger tex document. I found this helpful when writing a paper where the appendix needed over 35 different tables of regression results, all with…

That's a great point! Templates are a great tool to generate big tables from results, I usually do that for most of the results in my papers, makes it easier to have the odd copy/paste error. I might add this to the tips and tricks, thanks!

Re: Tips and tricks to write LaTeX papers in with figures generated in Python

#23
post #4

Thanks for the write-up! Two notes from my experience: pgf output works well with latex as well (although will slowdown compilation), and I recommend not using the pyplot submodule, especially if you'll be running things remotely over ssh and don't have a display

Indeed, I remember having to switch to Agg for this reason but can't remember why I switched back. Maybe some rendering issues I had with Agg, not sure...

Re: Tips and tricks to write LaTeX papers in with figures generated in Python

#24

One itch which (curiously) I can't seem to quite scratch in LaTeX is that it should be possible to say "plot equation \ref{eq:smth} for X in (-4,4)" and just get the bloody graph. Why should I need to define the equation again in a separate place, perhaps even in a separate file?

It's not exactly what you want, but you can do parametrized plots in TikZ to plot a given function for some range: http://www.texample.net/tikz/examples/parameterized-plots/.

I wouldn't be surprised if someone wrote a tool that allows you to use a reference to an equation as the function to plot :).

Re: Tips and tricks to write LaTeX papers in with figures generated in Python

#25

I have one tip for anyone using LaTeX: Please stop using the awful Computer Modern typeface.

I personally find Computer Modern quite pleasant to read and work with.

Apart from personal preference, why avoid Computer Modern?

Re: Tips and tricks to write LaTeX papers in with figures generated in Python

#26
I find it useful to work with plots in Jupyter notebooks. Use the "%matplotlib notebook" cell magic to get interactive plots inline.

Then you can use savefig when it looks good. Then save the code you used into some file near the Latex sources.

Re: Tips and tricks to write LaTeX papers in with figures generated in Python

#27
post #11

> When writing LaTeX documents, put one sentence per line in your source file. An interesting tip, never thought of that! It changes the way you write a bit, but it does make finding changes easier, finding errors easier, and forces you to think more about each sentence since you have to hit "enter" at the end of each one.

It also works much better with version control software (git). Not only does it help with diffs, as the article mention, but it makes merging way easier in case you and your coauthor change two adjacent sentences at the same time.

Re: Tips and tricks to write LaTeX papers in with figures generated in Python

#28
Having just completed a dissertation in LaTex, with figures online in Overleaf and Dropbox (some of them screenshots), scripts and data spread across two computers and an external hard drive, desperate last minute plot text changes right in the pdf, I just have to ask: WHY DIDN"T YOU POST ALL THIS SOONER?

Re: Tips and tricks to write LaTeX papers in with figures generated in Python

#29

I have one tip for anyone using LaTeX: Please stop using the awful Computer Modern typeface.

Any typeface in particular that you do recommend?

I used Bitstream-Charter [1] for my dissertation. It looks much better than Computer Modern.

My resume is typeset in Linux Libertine [2] which is used in this superlatively beautiful and elegant CV template by Dario Taraborelli [3]. Requires xelatex.

[1] http://www.tug.dk/FontCatalogue/charterbt/

[2] http://www.tug.dk/FontCatalogue/linuxlibertine/

[3] http://nitens.org/taraborelli/cvtex

Re: Tips and tricks to write LaTeX papers in with figures generated in Python

#30

I have one tip for anyone using LaTeX: Please stop using the awful Computer Modern typeface.

I personally find Computer Modern quite pleasant to read and work with. Apart from personal preference, why avoid Computer Modern?

It shows that you took an extra year to write your dissertation. ;-)

Just kidding, but I got my degree 25 years ago, and at the time, the students who tried to have a perfectly typeset document spent a lot of time on that pursuit.

Post reply on HN