4 ms·
> File-watcher or live-reloading. You can create a build/deploy loop fairly easily When I worked with latex more, I kept a ~/.Makefile-latex and a shell functi
by philsnow 4y ago
> File-watcher or live-reloading. You can create a build/deploy loop fairly easily
When I worked with latex more, I kept a ~/.Makefile-latex and a shell function that would pretty much just do
inotifywait -e modify -e move --recursive --monitor . | while read; do make --makefile ~/.Makefile-latex; done
and I kept emacs and xpdf in side-by-side windows. Whenever I'd save a file in emacs (or xfig or whatever), a second later xpdf would refresh the pdf (and stay on the same page). It took away some of the pain of working with latex.
edit: I used this complicated setup instead of LyX or whatever other "(la)tex IDE" because I had ancillary files like xfig diagrams that would get compiled to .eps files and gnuplot scripts that would render data into graphs, and the makefile knew how to generate everything.
- kwantam 4y agoVery nice! It turns out that latexmk has this functionality: latexmk -pvc -pdf foo.tex (It can be configured to HUP your pdf reader if needed, too.) I usually add something like this command as the `auto` target in my latex Makefiles, which works pretty nicely.
- philsnow 4y agoTIL about latexmk (which I gather is a perl script that handles a lot of the latex build deps, like running bibtex at the right time(s), for you automatically), thanks! I never really understood most of the TeX world. I cargo-culted the bits I needed to make: * articles for journal submissions (easy, they all provided packages or templates), * my thesis (somebody had written a latex class that took care of all the school's formatting requirements a ~decade prior), and * a resume, and never dug into the differences between tex, latex, miktex, texlive, auctex, lyx, pdftex, xetex, luatex etc etc etc etc etc. I was just to ask you if you knew of a 40000-foot overview of these kinds of things but stumbled across this article over at Overleaf: https://www.overleaf.com/learn/latex/Articles/What%27s_in_a_Name%3A_A_Guide_to_the_Many_Flavours_of_TeX https://www.overleaf.com/learn/latex/Articles/What%27s_in_a_... , it looks pretty apropos.
- earthscienceman 4y agoThis is funny, because I just wrote a (fish) shell script that does this as well because all of the tex IDEs are so painful. Mostly because the entire efficiency of latex is that you're editing text and can do it in a text editor like emacs and move things around very quickly. I don't want a new interface! But. I'm kind of proud. My shell script monitors the tex files for character changes and then once a (configurable) threshold of changes is met, it kicks off the compilation process. But the real game changer is that every time it compiles, if the compile is successful it commits the recent edits to a git branch. Then if I want, I can go through the git branch and see the entire history of edits for only versions of the document that compiled. It's a game changer in a big way. When I finish a section, I squash the minor edits into one commit and give it a good message and then commit the full thing to the main branch. Then there is where I can make sure my manuscripts look the way they should and do major revisions or collaborative edits. The icing on the cake is that the fish script monitors for a special keypress and will take actions. So I hit "c" to compile the tex, "b" to rerun the massive bibliography compilations, "s" to squash the commits into the main branch, and "l" to display log errors. It's a dream! Now I don't think about compilation at all, or when I should commit something minor to git (and fiddle with the commands). I just type away and watch/request the pdf refresh when I need it... and _actually_ get work done. My god. So happy. I just finished this today.
- andreareina 4y agoIf you're using emacs why not a save hook?
- philsnow 4y agoIIRC entirely because I didn't use emacs to edit the figures, I was using xfig and later some other figure drawing program I can't remember the name of. If I were just using a save hook (or flymake-mode, which I later used for similar things), when I edited a figure emacs wouldn't know about it so I'd have to either manually run the build or go to emacs and force a file write.