How to write solutions
You get what you see, but do you really want it?
You have probably prepared texts on a computer many times, using programs like Microsoft Word or its relatives. Word is a WYSIWYG editor, which means that we edit the output directly (What You See Is What You Get). However, this violates the principle of separating content and form.
Creating documents in TeX is similar to writing programs. You work with source code (in a text editor), which is then compiled (TeX does that) into the final form, such as PDF. To create documents using TeX, you need an editor, a compiler (TeX), and a viewer (such as Adobe Reader).
Why complicate your work compared to Word? As mentioned before, this approach leads to better separation of content and form (easy potential change of the final form). You can use our solution template, which includes everything you need. And if it involves typesetting mathematical expressions, TeX is the clear choice.
Overleaf
Overleaf is an online environment for creating and managing LaTeX documents, capable of compiling. The advantage is that you don't need to install anything, we have prepared a template for you, just sign in, copy the project, and you can start TeXing. Another advantage is the presence of an online storage and opening in a browser, so you can TeX from any device with a browser.
One disadvantage is that online assumes TeX compilation, but part of TeXing may involve generating a source file using a script, which may not be executable on Overleaf.
Procedure
Installation of a local compiler
Local installation provides more options, greater control, and functionality even offline.
We mentioned earlier how many programs are needed to compile TeX documents. You don't have to worry about finding and configuring all of them. For Windows, there is the MiKTeX TeX distribution MiKTeX, which takes care of everything for you.
Download the clickable installer from the MiKTeX website.
The distribution also includes the TeXworks editor. Open it and write the following document in UTF-8 (choose the encoding at the bottom right):
\documentclass[12pt,a4paper]{article}
% basic packages
\usepackage[utf8]{inputenc}
\usepackage[czech]{babel}
\usepackage[T1]{fontenc}
\usepackage[headheight=20pt,margin=2cm,tmargin=3cm, headsep=2cm]{geometry}
\usepackage{lmodern}
% header
\usepackage{fancyhdr}
\usepackage{lastpage}
\fancyhf{}
\cfoot{\thepage/\pageref{LastPage}}
\pagestyle{fancy}
% header content
\lhead{\textbf{Problem V-P}}
\rhead{Faculty of Mathematics and Physics, \textbf{Diligent Student}}
\begin{document}
Solution of the problem
\end{document}
We just need to replace the line Solution of the problem
with our solution. Anything after the %
character is considered a comment by the LaTeX compiler, until it encounters a new line. The compiler doesn't care how many lines we skip;
it will create a new line itself if the text doesn't fit on the current line, or we can force a new line using \\
.
Start the compilation with the green button. If everything is fine, the first page typeset by TeX will appear on the right side of the editor. It's a normal PDF file opened in the integrated viewer. You can use Ctrl+click to switch between the source code and the corresponding place in the PDF, and vice versa.
Other editors
There are a few other editors worth mentioning.
TeXstudio – has autocompletion that helps with LaTeX syntax
Visual Studio Code – a versatile text editor with many useful extensions
Math typesetting
For typesetting of math we choesed TeX. So let say how to do it. Short equations and variables in line we write in between dollar signs.
For numbers on dice $0 < n < 7$.
Larger and more complicated equations we write in block mode by writing it in between pair of dollar signs.
Resulting force is
$$
F = mg \sin(\alpha)\,.
$$
Macro arguments are enclosed between compound brackets (if the argument is a single character, they can be omitted). The most commonly used commands are
- superscripts
$2^5 = 32$
- squere root
$\sqrt{1-\sin^2(x)} = |\cos(x)|$
- fractions
$\frac{p}{q}$
- subscripts
$a_1$
If you don't want to install the whole TeX machine, you can use similar syntax in the equation editor in OO Writer and in MS Word.
Links
- TeX – Stack Exchange – comprehensive forum
- OEIS list mathematics symbols