Here I introduce some useful TeX-tips to write a research article using LaTeX on Mac OS X.
I assume that:
- TeX Live has been installed in your system;
- You have some knowledge on how to write a preamble, equations, how to section, how to use .bib files; i.e., basic knowledge on the structure of .tex files.
- Readers use LaTeX, but not LuaTeX.
How to view package documentations
On Terminal, issuing
texdoc XX
where XX is a package name, allows you to view a package documentation in PDF. For instance,
texdoc txfonts
will show you the txfonts-package documentation if available.
How to find file locations in TeXLive
Sometimes you may want to know the address of a certain package or more generally a certain file which is supposed to be somewhere in TeXLive. To this purpose, issuing
kpsewhich XX
on Terminal will tell you the address of a file XX. For instance, in my current system,
kpsewhich cleveref.sty
returned me:
/usr/local/texlive/2016/texmf-dist/tex/latex/cleveref/cleveref.sty
Reply letter
I found one fantastic example to create a sophisticated reply letter:
http://tex.stackexchange.com/questions/174833/running-numbers-for-comments/174834
Reference manager
I use BibDesk , which is (1) of course free, (2) very light, and (3) allowing automatic importation from a PDF. I am fully happy with BibDesk, but other options include Mendeley, JabRef, etc. Usage can be easily found online.
Dividing a document into multiple files
Personally I prefer to divide documents into multiple .tex files. For instance, issuing \input{ryosuke} allows for a inclusion of ryosuke.tex in my main document.
However, division of document incurs a large cost in terms of searching, replacing and editing phrases (e.g. when we want to convert a term “self-fertilization” to “selfing”, we have to issue replacement in all the associated .tex files).
In Mac OS X, the following UNIX code allows you to change a specific word (say) “A” to (say) “B” across files within the same directory:
grep -l 'A' ./*.tex | xargs sed -i.bak -e 's/A/B/g'
Please make sure to use this command in your working directory of .tex files. Otherwise, terrible issues can occur. I’d move all the .tex files into a temporary directory (after issuing, say, mkdir temp), and then issue the above command.
NB: In the above code, * indicates a wildcard, so that all the .tex files in the directory is subject to the command.