Live data from Hacker News

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

github.com

11–20 of 68 posts

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

#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.

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

#12

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?

LaTeX doesn't have enough information about what your notations mean. You can very well write nonsensical formulas that look pretty in LaTeX but are absolutely meaningless.

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

#13
post #8

Earlier quoted context omitted.

Would you suggest an alternative to pyplot? What problems does it cause for you?

I had problems using pyplot over ssh because it can assume there's a display and fail when it couldn't find one. Maybe this has changed. I use the OO interface. For example https://matplotlib.org/gallery/api/agg_oo_sgskip.html

Changing the plot backend should fix this.

  import matplotlib
  matplotlib.use('Agg')
  import matplotlib.pyplot as plt
https://stackoverflow.com/questions/2801882/generating-a-png...

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

#14
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.

Interestingly enough, I made a very similar comment[1] about code line length and only using one statement per line in another HN thread several days ago.

[1] https://news.ycombinator.com/item?id=19349464

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

#17
post #6

Meta: there seems to be an extra "in" in the title, that makes no sense to me, at least. Not a native speaker, though.

It's a careless transposition of "papers in LaTeX" → "LaTeX papers in" without removing the "in".

Indeed, sorry about that!

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

#19
post #3

> We also recommend to save the command used to generate a figure in the LaTeX file An approach I have adopted recently is Knitr[1], so this layer of indirection goes away. With knitr, my data goes directly into the paper repository, and then my Makefile has something like this: %.tex: graphs/%.Rnw Rscript -e "library(knitr); knit('$?')" The nice thing is exactly what the authors recommend: it's much easier to enforc…

Looks awesome, thanks for sharing!

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

#20
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 takes a while to get the "muscle memory" of adding a new line after each sentence but it does make things much easier!
Post reply on HN