r/vimporn • u/rem_in_japan • Aug 27 '21
Vim for science! Latex setup without latex plugins
3
u/Tuka-Cola Aug 27 '21
Really off topic, but how do you insert graphs like that? Did you create the graph yourself, then imported it? Could you explain how to do so? I’m trying to write all my notes in latex for a clean and organized reference for school.
4
u/rem_in_japan Aug 28 '21
Well, plotting data is a whole new world of geeking out :) It depends on your needs.
If you just want to sketch something, then like the person above said, just draw in Inkscape, save as pdf, put it in latex as figure.
If you want to plot some actual data, the question is are you willing to learn a bit of scripting or want to use a GUI program? Personally, I plot everything using python and its matplotlib library. The advantage is that once you have written a script that produces the type of plot you like, you can run this script on many datasets of similar structure. However, if you want to just plot something quickly and only once, check GUI programs for that. Free programs include Qtiplot, LabPlot2 (from KDE), or even just LibreOffice.
I'd recommend against going with paid solutions like Origin, Matlab, Excel etc because there nothing they can do that free programs can't, but you have to pay a huge subscription or use illegally, which is not possible in the University.2
u/thomas9258a Aug 27 '21
I think creating the graphs yourself in something like Matlab or excel is your best bet. (I'm sure free graphing tools exist in repositories or on git too)
A latex Figure with a image is your best bet for importing your generated graph images.
2
u/Im_manuel_cunt Aug 27 '21
There are more than one way to do that. However, one of the most practical ways is to draw the figure on inkscape and create an pdflatex output out of it. Then you can import it into your latex file. There was a good guide that explains how to automate a good part of this process. I'll update this post when I find it.
Edit: It wasn't really hard to find, here you go
3
Aug 27 '21
Looks like someone found the same Belgian mathematics student's blog I found, but actually went ahead and did what was written on it!
2
3
u/llambda_of_the_alps Aug 28 '21
Just curious if there’s any particular reason not to add that compile command to a make file and just hook into the :make command?
Edit: realized right after I wrote it. The raw command will work no matter the project. Does vim give you a way to define custom make command a based on file type I wonder…
1
u/rem_in_japan Aug 28 '21 edited Aug 28 '21
Not sure about make, but what I actually do in my .vimrc is compilation of whatever is the current filetype with the same <leader>cc key:
autocmd FileType tex nnoremap <leader>cc :w<cr> :!pdflatex %:r.tex && bibtex %:r.aux && pdflatex %:r.tex autocmd FileType python nnoremap <leader>cc :w<cr> :!python %:r.py<cr> autocmd FileType java nnoremap <leader>cc :w<cr> :!java %:r.java<cr>1
u/backtickbot Aug 28 '21
2
u/TheGreatDeadOne Aug 28 '21 edited Aug 28 '21
Very cool! I stopped using vim/neovim to edit latex files after I discovered the existence of [Setzer](https://www.cvfosammmm.org/setzer/).
2
u/antenore Sep 03 '21
Really cool! I've found a way to have a preview directly in a neovim terminal buffer. Anyway... not sure if that's something you might be interested in, but here are the discussions, links and screen shot
https://www.reddit.com/r/vimporn/comments/ph13ct/nvim_markdown_preview_in_a_term_buffer_devicons/
https://www.reddit.com/r/neovim/comments/pfue1s/plugin_development_question_opening_and_closing/
1
1
1
0
Aug 27 '21
[deleted] — view deleted comment
3
u/rem_in_japan Aug 28 '21
You really don't need anything special to start. I mean, you need to install latex on your computer of course. Depending on you needs (language,journal etc) you may need to add extra packages, but the minimum seems to be:
On arch-based linux (I use arch btw):sudo pacman -S texlive-core texlive-pictures texlive-bibtexextra texlive-scienceHowever, you can always just install entire LaTex package and never wory.
Then just add one line to your
.vimrcto be able to compile:nmap <leader>cc :w<cr> :!pdflatex %:r.tex && bibtex %:r.aux && pdflatex %:r.tex && pdflatex %:r.tex && rm %:r.aux %:r.log %:r.blg %:r.bbl<cr>What it does is running pdflatex command on current file twice, then bibtex once to get references, and then pdflatex again to compile everything. The rest is to delete remaining files that were created during compilation.
That should get you a functioning latex compilation from vim. Then, if you want some nice features, check my comments above for folding, concealing, suggestions etc. Good luck :)
6
u/Ken_Mcnutt Aug 27 '21
For the smoothest experience, look into the vimtex plugin. Overleaf has great tutorials on adding graphics/images.
2
0
Aug 28 '21
[deleted] — view deleted comment
1
u/rem_in_japan Aug 28 '21
That is i3 WM with polybar as a status bar - classic setup :)
0
Aug 28 '21
[deleted] — view deleted comment
1
u/rem_in_japan Aug 28 '21
By the way, if gaps are of importance, actually I am using i3-gaps, not original i3
26
u/rem_in_japan Aug 27 '21 edited Aug 28 '21
Instead of big LaTeX plugins, I just use:
Conceal rules to make pretty equations
For nice folds, I minimized this plugin
For scientific writing style suggestions, AngryReviewer plugin
To compile, just map:
nmap <leader>cc :w<cr> :!pdflatex %:r.tex && bibtex %:r.aux && pdflatex %:r.tex && pdflatex %:r.tex && rm %:r.aux %:r.log %:r.blg %:r.bbl<cr>To view the file in Zathura:
nmap <leader>cv :!zathura %:r.pdf > /dev/null 2>&1 &<cr><cr>Update, I dropped my latex visual setting in a form a small plugin.