We like typing our documents (scientific or not) in Latex because it is clean and powerful. But sometimes, it is cumbersome because to preview the result, you first have to typeset (sort of compiling) and view the document in a document viewer, whether DVI or PDF. This is much more difficult and time consuming than when a regular word processor such as Word is used. Of course, I don't mention the use of Latex GUIs such as Scientific Workplace (on Windows) because it is even more cumbersome and document created in this environment are very difficult to share with non SW users.
After some time on Mac, I have found the ideal setup (for me) and a great workflow. It is easy to install, to use and you almost get "Live Preview". What I mean by Live Preview is that you can type in your text editor latex code and get almost an instantaneous preview of the final document in PDF.
The trick involves a few softwares:
After some time on Mac, I have found the ideal setup (for me) and a great workflow. It is easy to install, to use and you almost get "Live Preview". What I mean by Live Preview is that you can type in your text editor latex code and get almost an instantaneous preview of the final document in PDF.
The trick involves a few softwares:
Mactex is the easiest way I know to install a Tex package on a Mac. Textmate is a great text editor. One thing is that it is not free :-( but you won't regret paying for it (A trial version is availabe). It can replace the simple editor bundled with OS X, and it makes things really easy. Skim is the fastest PDF viewer I know of for Mac. So download MacTex and install it, this should be fairly easy. Install Textmate and finally install Skim.
Now let's try creating a Latex document. Open Textmate and create a new document if necessary, and look at the bottom bar. You should see the type of the document and by default it is "Plain text". Click on that area and in the list menu choose "Latex" (alternatively you can try File Menu-->New from template-->Latex-->Article). Now you've told Textmate that you'll be typing a Latex document. You can try writing any Latex code you want. Let's remain simple and type this:
\documentclass{article}
\begin{document}
Hello there !
\end{document}
Now before previewing our document, let's make sure Textmate is properly configured for Latex. Go in the Bundles menu and do: Bundle Menu-->Latex-->Preferences. In the Latex Preferences dialog, make sure the Default engine is "pdflatex" (that's my advice). Then in dropdown menu View in choose "Skim", check "Show pdf automatically". You're done so click "Done".
Now you can preview your final document as a PDF in Skim. The shortcut to do that is "Command+r" . Try that and you should see the "Typeset and view" console that report the typesetting process and show errors and warnings. Skim should open automatically, steal focus and show you your newly created PDF. Great !
Now for the "Live Preview" (almost) workflow part. Here's what I like to do. I trim the Textmate window so that it occupies half the horizontal space on my screen. The other half is for Skim. This is already a neat setup: you type in Textmate, you press "Command+r" and you see the result in Skim very fast. But you can do better. First go in the Textmate preferences: Textmate Menu-->Preferences. Go to the "Advanced" tab and in the "Saving" sub tab. Now you have to check two option:
Now let's try creating a Latex document. Open Textmate and create a new document if necessary, and look at the bottom bar. You should see the type of the document and by default it is "Plain text". Click on that area and in the list menu choose "Latex" (alternatively you can try File Menu-->New from template-->Latex-->Article). Now you've told Textmate that you'll be typing a Latex document. You can try writing any Latex code you want. Let's remain simple and type this:
\documentclass{article}
\begin{document}
Hello there !
\end{document}
Now before previewing our document, let's make sure Textmate is properly configured for Latex. Go in the Bundles menu and do: Bundle Menu-->Latex-->Preferences. In the Latex Preferences dialog, make sure the Default engine is "pdflatex" (that's my advice). Then in dropdown menu View in choose "Skim", check "Show pdf automatically". You're done so click "Done".
Now you can preview your final document as a PDF in Skim. The shortcut to do that is "Command+r" . Try that and you should see the "Typeset and view" console that report the typesetting process and show errors and warnings. Skim should open automatically, steal focus and show you your newly created PDF. Great !
Now for the "Live Preview" (almost) workflow part. Here's what I like to do. I trim the Textmate window so that it occupies half the horizontal space on my screen. The other half is for Skim. This is already a neat setup: you type in Textmate, you press "Command+r" and you see the result in Skim very fast. But you can do better. First go in the Textmate preferences: Textmate Menu-->Preferences. Go to the "Advanced" tab and in the "Saving" sub tab. Now you have to check two option:
- First check "Perform atomic saves". Atomic saves mean that (Textmate definition) instead of overwriting the file, TextMate saves to a new file and once this succeeds, overwrites the old file. This has the advantage that if your machine should crash while saving a file, you do not run the risk of losing the contents of both the old (last-saved) and new files
- Second check "Save files when focus is lost": this is an interesting option. It means that each time you click anywhere outside the Textmate application, Textmate's focus is lost and your current work in Textmate is automatically saved !
OK! We're almost done. One last thing to do is to tell Textmate to monitor file saving and update final preview. To do that do: Bundles Menu-->Latex-->Watch document (alternatively use the shortcut Control+Command+w). Now a new PDF of your work will be created but this one is special (you can close the old one). The Watch document option does something pretty neat: it will automatically preview your document in Skim each time you save it. But as we've told Textmate to save automatically each time focus is lost, to have an almost "Live Preview" all you need to do is type, and then click on Skim (by clicking Skim or elsewhere outside of Textmate, Textmate loses focus, autosaves, and the Watch document option creates a new preview). Pretty good !
If this is not enough, we can go one step further however this step can be as much useful as a pain in the a$$. This is a trick I pulled directly from Textmate Howto Wiki. The idea now is to use something to autosave the Latex document for you every specified time. That thing is called EverSave ! This free little app save your work in almost any app for you. Download and install it. Once you're done go inside EverSave's preferences and do the following:
That's it ! Let me know if you find this useful in your comments.
If this is not enough, we can go one step further however this step can be as much useful as a pain in the a$$. This is a trick I pulled directly from Textmate Howto Wiki. The idea now is to use something to autosave the Latex document for you every specified time. That thing is called EverSave ! This free little app save your work in almost any app for you. Download and install it. Once you're done go inside EverSave's preferences and do the following:
- In the General tab, make sure "Listed applications" is the option under Save Applications and "Frontmost only" under Save Documents. Under When should EverSave save check only "Timer-controlled". Uncheck everything else inside this tab.
- Go to the Applications tab and under Automatically save these applications click "+" and browse to your application folder to add Textmate. Automatically add applications options should be unchecked.
- Go to the Timer tab. You have to choose a Save delay. EverSave will use this to save the document in Textmate every said time. I suggest putting something like 10 seconds or less. Then under Please choose a save method you absolutely need to choose "Save by simulating save shortcut", the other option is useless with Textmate as a save dialog will prompt each time.
That's it ! Let me know if you find this useful in your comments.








