Writing with LaTeX

Just as what other tools I use every day, Linux and Vim, they are all unfriendly tools to beginners. However, when you get familiar with them, you can find that they are the best tools you can find in the world.

· 5 min read
Writing with LaTeX

When separating researchers with the tool they use to write their papers, three factions can be formed: LaTeX, MS Word and others. As you can see from the title, my favorite tool is LaTeX. Just as what other tools I use every day, Linux and Vim, they are all unfriendly tools to beginners. However, when you get familiar with them, you can find that they are the best tools you can find in the world.

Different from MS Word and other similar software, whose typesetting result can be directly previewed simultaneously, LaTeX is a markup language that requires you to compile your code of content and typesetting to your real paper. However, there is one problem and the biggest problem for both LaTeX and other markup languages, the readability.

Some complex formulas in LaTeX

Since the paper content and typesetting marks together with other control commands are all mixed up in the LaTeX code, to clearly view your paper, you need to first compile it to a PDF file and then view the results. Even though, the paper layout is always far more beautiful than that of MS Word as far as I am thinking.

To gain more readability of the content you are writing, and write and insert tables, images and diagrams more easily, we need to use other tools to help us generate the LaTeX code we want, rather than we manually write that.

The tools that I will introduce in this passage are all that I use to write my papers. However, as a non-professional LaTeX user, what I introduced may not fit everybody. So, if you have better suggestions, you can also introduce them to me.

First of all, the most important tool I use is a good template. The template I mentioned here is not the paper template provided by your publisher, it is just a "layout" file of your LaTeX code structure, which can help you to handle all other things apart from the paper content. And the real contents of your paper (usepackages, abstract, authors and the body of the paper) are located in other corresponding specific files (the component file). A good template cannot only help you separate your LaTeX structure code and your real content, but it can also help to quickly change publisher templates, replace words and so on.

There are four components for the template file. At the top is the "header" part. In this part, you need to set the paper template that is used, and import two other component files, usepackages and definitions, which import the packages you will use in this paper with the \usepackage command, and define the constants that will be used in the whole paper respectively. In my definition file, the paper title and keywords are also defined, which will be used in the "title" part of the template.

The header part of my IEEE paper template

The second part is the "title" part. This part begins from the \begin{document} command and ends before your main body of your paper. In this part, you need to set the paper title and keywords which have been defined in the definition file, and import the abstract file which contains the entire abstract content. And after the abstract, the template needs to config other settings that are required by the publisher template (e.g. the CCSXML block required by the ACM template) or just some other configurations you need.

The title part of my IEEE paper template

The third part is the main body of your paper, it contains only the \input{content.tex} commend to import the content file. And the last part is the "bibliography" part. In this part, the template is required to set the BibTeX format and import the bibliography file.
With this template, you can transfer your paper to another publisher template by only copying the usepackage, definition, abstract, content and bibliography file to another project. Simple and convenient. And since the idiomatic usages are all defined in the definition file as user-defined commands, they can be used everywhere in your paper content.

The bibliography part of my IEEE paper template

Since the abstract and main body of the paper is written in other files other than the LaTeX structure, you can write the paper content directly with markdown and convert it to LaTeX with pandoc. Yes, pandoc is the second tool I use to help me write the paper.

Apart from the paper content, there will always be a lot of tables and images in the paper to help the reviewer to understand your ideas. And similar to the content, they are usually not manually written.

For tables, pandoc markdown can also be used. However, when you do some statistics, you always need spreadsheets. The third thing I will introduce here is the google spreadsheet together with the SpreadLaTeX plugin.

Pipe line table in markdown and generated table in PDF file

In google spreadsheet, you can use not only the normal functions available in MS Spreadsheet, but use SQL queries for the sheet as well. And with the SpreadLaTeX plugin (available from the G Suite Marketplace), you can export the selected area as LaTeX code and vice versa, and the exported LaTeX code will convert all formulas in the sheet cells into its result values. Besides, you can also generate diagrams with the statistics in the sheet and export the diagrams in PDF format.

Generating LaTeX table code from Google SpreadSheet

When it comes to charts, people usually prefer to draw them, rather than write them. The tool I usually use to draw charts is google drawings. This tool can usually be used to draw some simple charts, as the dot code generated charts are always too ugly to be used.

With these above tools, you can now start writing your pages with LaTeX. Then you will see that there is no difference with writing simple documentation with something like markdown or MS Word, and LaTeX is not as difficult as you thought before.