When submitting a solution in C++, please select either C++14 (GCC 6-32) or C++17 (GCC 7-32) as your compiler. ×

Sammarize's blog

By Sammarize, 8 years ago, translation, In English

In this post I want to describe in short how to write a formulas on Codeforces. In fact it is short introduction to the markup language used on Codeforces.

Three important rules.

Foremost rule: formula me place in dollars ($), as well as in parentheses.

Another important rule: if you want to apply some operation to some group of symbols it is necessary to form the block using the curly braces. For instance, 2^x+y = 2x + y, but 2^{x+y} = 2x + y.

Third rule — for perfectionists. For traffic economy Codeforces print simple formulas by usually text. Sometimes it is not very pretty: C_{x_i+y_i-2}^{x_i-1} = Cxi + yi - 2xi - 1. Is this case you can add command \relax at the beginning of the formula. Then the formula is guaranteed to be beautiful: \relax C_{x_i+y_i-2}^{x_i-1} = .

Arithmetic operations.

Addition and subtraction can be written ordinary symbols + and -. Multiplication is usually indicated by a null character (xy is the produst of numbers x and y) or by symbol (\cdot). If it is necessary to multiply two complex expressions (), or are important both factors, not just the value of the product (in expressions of type field ), use the symbol  × , which may be obtained by the command \times.

The division is somewhat more complicated. Usually in mathematics division is not written in one line, but the desire is not to write the fraction of the blue, too, is understandable. In this case, you can always write a : or / (x:y, x/y).

If you want to write all the same fraction, it has two similar commands: \frac and\dfrac. After any of these commands have to write a block of the numerator and block of the denominator, for example: (\frac{1}{4}). Using \frac small fractions are obtained, which is suitable mainly for the simple fractions. If you want to write a serious big fraction you'll need \dfrac: (\dfrac{x+y}{x^2+y^2}). If the numerator and denominator of a single-character, it can not be enclosed in brackets, for example: (\frac14x), but only if the numerator is not a letter.

The upper and lower indices.

If you want to write a lower index, you will help symbol _ and upper index (basically it is the exponent), the symbol^: (xi + yi)2 ((x_i + y_i) ^ 2). Same manner as with the fractions in the lower or upper index block can be placed, but if a single-character index, it can not do so.

Other useful tips and special characters

Text — text (---) — not in the formulas, and in the text. This dash, not hyphen (it is not works without surrounding text)
(\dots) — three dots symbol.
(\infty) — infinity symbol.
(\in) and (\ni) — element of the set.
 →  (\to) — arrow right, in expressions such as xn → 0.
Many well-known mathematical functions can be typed with the '\', then they will look like a formula, rather than simply as text ( = \tg, = \ln, = \lim and so on)
If you want to index are top and bottom rather than the top-right and bottom-right, use the command \limits:
= \sum_{k = 0}^nx^k
= \sum\limits_{k = 0}^nx^k.
If the brackets around a large expression small, you can make them suitable size, written before the left bracket command \left, and before right bracket command \right. For instance: = \left( \dfrac{x+y}{x^2+y^2} \right).

Thank you for the attention!

Tags tex
  • Vote: I like it
  • +380
  • Vote: I do not like it

| Write comment?
»
8 years ago, # |
Rev. 12   Vote: I like it 0 Vote: I do not like it

X × Y x·y

»
8 years ago, # |
  Vote: I like it +5 Vote: I do not like it

I find this very useful. Thank a lot, will start using it.

»
8 years ago, # |
  Vote: I like it +8 Vote: I do not like it

Thanks for your post! Here are a few more notes:

To get a binomial coefficient (the number of ways to choose k objects out of n total), you can write \binom{numerator}{denominator}.

You can put an equation on its own line by separating two dollar signs with line breaks:

[two dollar signs]
equation
[two dollar signs]

which yields

Add \displaystyle at the beginning to make things look nicer.

AoPS has a nice latex guide here (helpful sections are symbols and commands).

»
8 years ago, # |
Rev. 3   Vote: I like it +3 Vote: I do not like it

Thanks a lot, add another one "signed area of triangle" A is stand for the signed area of a triangle,

(2A=
\begin{vmatrix}
x_0 & y_0 & 1 \
x_1 & y_1 & 1 \
x_2 & y_2 & 1 \
\end{vmatrix}
=x_0y_1+x_2y_0+x_1y_2-x_2y_1-x_0y_2-x_1y_0
) btw:two dollar signs are Omitted
for more useful tips of LaTeX, this website may help
http://meta.math.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

»
6 years ago, # |
  Vote: I like it +8 Vote: I do not like it

 ×  has a different purpose from scalar multiplication. For example, cross product, or Cartesian product N × M. And, of course,  *  has a different purpose again; typically, it's a superscript or denotes convolution.

You can always use parentheses and common · for scalar multiplication, regardless how complex the expressions are.

»
4 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Nice blog, please add the symbol "$$$\in$$$" its \in.

Also why this blog has too few comments?

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

$$$\int\limits_{t=0}^{t=\infty}\mathbb{E}[X_t] dt $$$

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

You can go here to get more information https://katex.org/docs/supported.html

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

$2^x+y

  • »
    »
    3 years ago, # ^ |
      Vote: I like it +10 Vote: I do not like it

    Put the dollar symbol at the beginning and at the end of your formula.

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

how to change line while writing?