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

  1. Register on Overleaf, either using Google or an email address
  2. Open our template
  3. Start editing the template (name, task type, series number)
  4. You can start TeXing. Look up LaTeX tutorials as needed (Hint: Overleaf has quite good tutorials for beginners.)

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

Sazba matematiky

Kvůli sazbě matematiky jsme si zvolili TeX. Řekněme si tedy, jak na to. Krátké vzorečky, vztahy a proměnné se sází v řádkovém režimu mezi dolary

Pro čísla na kostce platí $0 < n < 7$.

Větší a složitější vzorce sázíme v blokovém režimu mezi dvojice dolarů.

Síla je dána jako
$$
F = mg \sin(\alpha)\,.
$$

Argumenty maker se uzavírají mezi složené závorky (je-li argument jeden znak, je možné je vynechat). Nejčastěji používanými příkazy jsou

  • mocnění $2^5 = 32$
  • odmocňování $\sqrt{1-\sin^2(x)} = |\cos(x)|$
  • zlomky $\frac{p}{q}$
  • dolní index $a_1$

Pokud nechcete instalovat celou TeXovou mašinérii, lze použít podobnou syntaxi v editoru rovnic v OO Writeru i v MS Wordu.

Odkazy

If you are looking for the old website, you may find it at https://old.fykos.org