# [Tex/LaTex] How to create a set in LateX

math-operators

I am very lost. I haven't been liking LaTeX as it's quite hard for me to get the hang of it, so I've decided to practice on my own during the summer, but I am already stuck on something that seems very basic.

I want to write sets. How do I create the brackets {}?
You know, say {2,4,6,8…} or {x|x is positive and even}. I tried ${2,4,6...}$ But this ignores the brackets.

I was searching if there is a specific command to create that say
\Set{2,4,6...} or something similar. But no, it's an error and I cannot find such information.

I have given up, how do I create a set notation nicely??? Really simple things seem very… obscure to me with LaTeX and requires great hassle.
Is there any where good, a website, for me to learn this? Had a hard time in university last year, some people got easily okay with it but this is just not my cup of tea…. Seems to unnecessarily complicate something that could be done simpler…. Help is greatly appreciated! Thanks in advance.

To quote from Leslie Lamport's "LaTeX: A Document Preparation System" (Leslie Lamport initially developed LaTeX):

The ten special characters

# $% & ~ _ ^ \ { } are used only in LaTeX commands. ... Seven of those symbols can be produced by typing a \ in front of the corresponding character.$ & % # _ { } are easy to produce.

In other words, to get { and } you must type \{ and \}. This is because { and } mean something very special to LaTeX. They are used to delimit arguments. So with something like \emph{Hi}, the emphasis starts at the { and finishes at the } (\emph is a command which is used to emphasise text; the standard behaviour is for it to italicise it). In other words, everything enclosed within the braces is emphasised.

As such, if you want to print the symbols { and }, you can't just type the plain symbol. Instead you must "escape" it. The \ is the escape character and it basically tells LaTeX to pay attention. emph is just a word like any other to LaTeX. But \emph is a command to LaTeX. What escaping a { does is cause LaTeX to print a { character.

So to get {2,4,6,8...}, all you need to do is type:

$\{2, 4, 6, 8\dots\}$

To get {x|x is positive and even}, you can do:

$\{x \mid x \text{ is positive and even}\}$

As raised in the comments - this relies on the amsmath package. Instead, you can do:

$\{x \mid x \mbox{ is positive and even}\}$

For most purposes, this has the same effect, but there are minor differences:

Difference between various methods for producing text in math mode

$\{\,x \mid x \text{ is positive and even}\,\}$
As you can see, \, inserts a thin space. There are other commands for inserting space in LaTeX. However, \, is one of only two that can be used outside of math-mode.