How do you create a set in LateX?
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.
math-operators
|
show 2 more comments
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.
math-operators
2
Welcome! This has nothing to do withlatex3
so I will edit the tags in a moment. However, please try${thing 1, thing 2, thing 3}$
.
– cfr
Jul 1 '15 at 3:26
2
I'd recommend Kopka and Daly's A Guide to LaTeX. I realise that recommending books is a bit old-fashioned but I think it makes this kind of thing a lot easier, to be honest. All the basics covered in an order which makes sense and ensures that you have a sense of both the big picture and the details. The other thing is to make sure you have a good editor. Most editors will help you out with this kind of thing - especially with the code for symbols.
– cfr
Jul 1 '15 at 3:31
1
Welcome from me as well! My friend, it's no wonder you're not getting on with LaTeX if you haven't - haven't been taken through the basics (whether by a person, or a book). Myself, I actually got started with the wikibooks LaTeX manual (en.wikibooks.org/wiki/LaTeX), which I think is a very good place to start, but there are quite possibly better resources out there - @cfr's seem good. But if you don't understand the principles of LaTeX, you're not going to have an easy time with it. Not that learning by doing isn't the way to go - it is, but you have to understand 1st principles.
– Au101
Jul 1 '15 at 3:41
1
Have you seen What are good learning resources for a LaTeX beginner?
– clemens
Jul 1 '15 at 7:49
2
The general answers that help you learn LaTeX are good ones. There's an answer to your particular question here: tex.stackexchange.com/questions/209863/…
– Ethan Bolker
Jul 1 '15 at 16:09
|
show 2 more comments
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.
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.
math-operators
math-operators
edited Jul 1 '15 at 3:29
cfr
157k8191390
157k8191390
asked Jul 1 '15 at 3:23
Melba1993Melba1993
221126
221126
2
Welcome! This has nothing to do withlatex3
so I will edit the tags in a moment. However, please try${thing 1, thing 2, thing 3}$
.
– cfr
Jul 1 '15 at 3:26
2
I'd recommend Kopka and Daly's A Guide to LaTeX. I realise that recommending books is a bit old-fashioned but I think it makes this kind of thing a lot easier, to be honest. All the basics covered in an order which makes sense and ensures that you have a sense of both the big picture and the details. The other thing is to make sure you have a good editor. Most editors will help you out with this kind of thing - especially with the code for symbols.
– cfr
Jul 1 '15 at 3:31
1
Welcome from me as well! My friend, it's no wonder you're not getting on with LaTeX if you haven't - haven't been taken through the basics (whether by a person, or a book). Myself, I actually got started with the wikibooks LaTeX manual (en.wikibooks.org/wiki/LaTeX), which I think is a very good place to start, but there are quite possibly better resources out there - @cfr's seem good. But if you don't understand the principles of LaTeX, you're not going to have an easy time with it. Not that learning by doing isn't the way to go - it is, but you have to understand 1st principles.
– Au101
Jul 1 '15 at 3:41
1
Have you seen What are good learning resources for a LaTeX beginner?
– clemens
Jul 1 '15 at 7:49
2
The general answers that help you learn LaTeX are good ones. There's an answer to your particular question here: tex.stackexchange.com/questions/209863/…
– Ethan Bolker
Jul 1 '15 at 16:09
|
show 2 more comments
2
Welcome! This has nothing to do withlatex3
so I will edit the tags in a moment. However, please try${thing 1, thing 2, thing 3}$
.
– cfr
Jul 1 '15 at 3:26
2
I'd recommend Kopka and Daly's A Guide to LaTeX. I realise that recommending books is a bit old-fashioned but I think it makes this kind of thing a lot easier, to be honest. All the basics covered in an order which makes sense and ensures that you have a sense of both the big picture and the details. The other thing is to make sure you have a good editor. Most editors will help you out with this kind of thing - especially with the code for symbols.
– cfr
Jul 1 '15 at 3:31
1
Welcome from me as well! My friend, it's no wonder you're not getting on with LaTeX if you haven't - haven't been taken through the basics (whether by a person, or a book). Myself, I actually got started with the wikibooks LaTeX manual (en.wikibooks.org/wiki/LaTeX), which I think is a very good place to start, but there are quite possibly better resources out there - @cfr's seem good. But if you don't understand the principles of LaTeX, you're not going to have an easy time with it. Not that learning by doing isn't the way to go - it is, but you have to understand 1st principles.
– Au101
Jul 1 '15 at 3:41
1
Have you seen What are good learning resources for a LaTeX beginner?
– clemens
Jul 1 '15 at 7:49
2
The general answers that help you learn LaTeX are good ones. There's an answer to your particular question here: tex.stackexchange.com/questions/209863/…
– Ethan Bolker
Jul 1 '15 at 16:09
2
2
Welcome! This has nothing to do with
latex3
so I will edit the tags in a moment. However, please try ${thing 1, thing 2, thing 3}$
.– cfr
Jul 1 '15 at 3:26
Welcome! This has nothing to do with
latex3
so I will edit the tags in a moment. However, please try ${thing 1, thing 2, thing 3}$
.– cfr
Jul 1 '15 at 3:26
2
2
I'd recommend Kopka and Daly's A Guide to LaTeX. I realise that recommending books is a bit old-fashioned but I think it makes this kind of thing a lot easier, to be honest. All the basics covered in an order which makes sense and ensures that you have a sense of both the big picture and the details. The other thing is to make sure you have a good editor. Most editors will help you out with this kind of thing - especially with the code for symbols.
– cfr
Jul 1 '15 at 3:31
I'd recommend Kopka and Daly's A Guide to LaTeX. I realise that recommending books is a bit old-fashioned but I think it makes this kind of thing a lot easier, to be honest. All the basics covered in an order which makes sense and ensures that you have a sense of both the big picture and the details. The other thing is to make sure you have a good editor. Most editors will help you out with this kind of thing - especially with the code for symbols.
– cfr
Jul 1 '15 at 3:31
1
1
Welcome from me as well! My friend, it's no wonder you're not getting on with LaTeX if you haven't - haven't been taken through the basics (whether by a person, or a book). Myself, I actually got started with the wikibooks LaTeX manual (en.wikibooks.org/wiki/LaTeX), which I think is a very good place to start, but there are quite possibly better resources out there - @cfr's seem good. But if you don't understand the principles of LaTeX, you're not going to have an easy time with it. Not that learning by doing isn't the way to go - it is, but you have to understand 1st principles.
– Au101
Jul 1 '15 at 3:41
Welcome from me as well! My friend, it's no wonder you're not getting on with LaTeX if you haven't - haven't been taken through the basics (whether by a person, or a book). Myself, I actually got started with the wikibooks LaTeX manual (en.wikibooks.org/wiki/LaTeX), which I think is a very good place to start, but there are quite possibly better resources out there - @cfr's seem good. But if you don't understand the principles of LaTeX, you're not going to have an easy time with it. Not that learning by doing isn't the way to go - it is, but you have to understand 1st principles.
– Au101
Jul 1 '15 at 3:41
1
1
Have you seen What are good learning resources for a LaTeX beginner?
– clemens
Jul 1 '15 at 7:49
Have you seen What are good learning resources for a LaTeX beginner?
– clemens
Jul 1 '15 at 7:49
2
2
The general answers that help you learn LaTeX are good ones. There's an answer to your particular question here: tex.stackexchange.com/questions/209863/…
– Ethan Bolker
Jul 1 '15 at 16:09
The general answers that help you learn LaTeX are good ones. There's an answer to your particular question here: tex.stackexchange.com/questions/209863/…
– Ethan Bolker
Jul 1 '15 at 16:09
|
show 2 more comments
4 Answers
4
active
oldest
votes
To answer your specific question:
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, 8dots}$
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
For really nice spacing, follow Hagen von Eitzen's advice and use:
${,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.
But, really, it's important that you gain an understanding of the basic operating principles of LaTeX before you go further and start worrying about how to do specific things; otherwise you're gonna be completely at sea and everything's gonna seem like black magic and nonsense. So I really recommend you have a little look through some basic introductions before diving right in there.
However I learned by doing - I learned by trying it out, I learned by using LaTeX and looking things up whenever I wanted to do something I didn't yet know how to do. That's a very fulfilling, very enjoyable and very practical way to learn - although there are massive holes in my knowledge and, because my approach was very light on theory, I'm only just starting to learn about bad habits I've developed and principles I may have overlooked.
But still, as good as it is to dive in there and get your hands dirty, you have to, have to get a basic idea of what LaTeX is and how it works or you'll probably continue to have a pretty miserable time. It's no wonder you don't like it and everything seems arcane and difficult and a complete pain in the posterior to you!
Also, in setbuilder notations as this I'd add spacing as in${,x mid x text{ is positive and even},}$
– Hagen von Eitzen
Jul 1 '15 at 9:46
Sorry @MarcvanDongen, didn't realise. If nothing else, it demonstrates quite nicely something I overlooked because I never read about it, because I just assumed I knew how to do it, because of the "dive right in" approach I took :P
– Au101
Jul 1 '15 at 22:02
add a comment |
LaTeX puts at your disposal the package braket
that helps you creating beautiful sets, kets and bras for the Dirac notation. In particular
set{x, mid x<2}
ket{psi}
bra{phi}
do the job as simple as that as shown below:
Let $A=set{xmid psi(x)>0}$; also, given
$ket{psi}inmathcal{H}$, then $psi(x)coloneqqbraket{x|psi}$.
1
Well, thesets
command frombraket
is definitely useful, but the question has nothing to do withbra
andket
from Dirac notation in Hilbert space. I suggest to elaborate on your answer.
– Christian Hupfer
Jul 1 '15 at 21:58
To make your question useful and self contained, please make a MWE and also show the output itself.
– Nasser
Jul 1 '15 at 22:10
Is it not possible to display LaTeX outputs as per LaTeX tags in this section? I have tried (and failed) to display a working example.
– gented
Jul 1 '15 at 22:15
One saves a screen dump into a jpeg and crops it. Then, one can attach the image to their answer by clicking the icon that looks like a picture.
– Steven B. Segletes
Jul 2 '15 at 1:46
Thank you, I have done so. However, is there no way to show LaTeX markup inside the text? Other sections of the site do.
– gented
Jul 2 '15 at 20:15
|
show 3 more comments
Here's an option with mathtools
package. I show here the different possible sizes and usage.
documentclass{scrartcl}
usepackage{mathtools}
DeclarePairedDelimiterXset[1]lbracerbrace{defgiven{;delimsizevert;}#1}
begin{document}
$set{ x given x > 0 }$
$set[big]{ x given x > 0 }$
$set[Big]{ x given x > 0 }$
$set[bigg]{ x given x > 0 }$
$set[Bigg]{ x given x > 0 }$
$set*{ x given x > 0 rule{0cm}{2cm} }$ % rule is just here so you can see that it autostretches
end{document}
If you prefer to use set{ x | x > 0 }
rather than set{ x given x > 0 }
you can do
DeclarePairedDelimiterXset[1]lbracerbrace{setaux#1}
defsetaux#1|{#1;delimsizevert;}
To the pro users: I would welcome some help with the checking for a|
inside the argument in the second option. I believe it has something to do with som sort ofdefsetaux#1|#2|#3endsetaux{ifrelaxdetokenize{#2}relax #1 else #1 ;delimsizevert; #2 fi}
and call it withsetaux #1||endsetaux
. But I'm not certain (it probably has an error).
– Manuel
Jul 1 '15 at 22:08
Manuel — looks about right to me:)
– Will Robertson
Jul 2 '15 at 1:19
add a comment |
I defined a new command set
based on xparse
package. The result is nice-looking.
documentclass{article}
usepackage{xparse}
NewDocumentCommand{set}{o m}{%
% <code>
IfNoValueTF{#1}
{{#2}}
{{#1 mid #2}}%
% <code>
}
begin{document}
$set{x_1, dots}$ or ${set[x in X]{phi(x)}}$
end{document}
1
I edited your answer to make it more like an answer (with a complete and compilable code as well as an image of the result). If you don't like it, be free to roll back to the original version.
– JouleV
Feb 27 at 8:18
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f253077%2fhow-do-you-create-a-set-in-latex%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
To answer your specific question:
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, 8dots}$
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
For really nice spacing, follow Hagen von Eitzen's advice and use:
${,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.
But, really, it's important that you gain an understanding of the basic operating principles of LaTeX before you go further and start worrying about how to do specific things; otherwise you're gonna be completely at sea and everything's gonna seem like black magic and nonsense. So I really recommend you have a little look through some basic introductions before diving right in there.
However I learned by doing - I learned by trying it out, I learned by using LaTeX and looking things up whenever I wanted to do something I didn't yet know how to do. That's a very fulfilling, very enjoyable and very practical way to learn - although there are massive holes in my knowledge and, because my approach was very light on theory, I'm only just starting to learn about bad habits I've developed and principles I may have overlooked.
But still, as good as it is to dive in there and get your hands dirty, you have to, have to get a basic idea of what LaTeX is and how it works or you'll probably continue to have a pretty miserable time. It's no wonder you don't like it and everything seems arcane and difficult and a complete pain in the posterior to you!
Also, in setbuilder notations as this I'd add spacing as in${,x mid x text{ is positive and even},}$
– Hagen von Eitzen
Jul 1 '15 at 9:46
Sorry @MarcvanDongen, didn't realise. If nothing else, it demonstrates quite nicely something I overlooked because I never read about it, because I just assumed I knew how to do it, because of the "dive right in" approach I took :P
– Au101
Jul 1 '15 at 22:02
add a comment |
To answer your specific question:
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, 8dots}$
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
For really nice spacing, follow Hagen von Eitzen's advice and use:
${,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.
But, really, it's important that you gain an understanding of the basic operating principles of LaTeX before you go further and start worrying about how to do specific things; otherwise you're gonna be completely at sea and everything's gonna seem like black magic and nonsense. So I really recommend you have a little look through some basic introductions before diving right in there.
However I learned by doing - I learned by trying it out, I learned by using LaTeX and looking things up whenever I wanted to do something I didn't yet know how to do. That's a very fulfilling, very enjoyable and very practical way to learn - although there are massive holes in my knowledge and, because my approach was very light on theory, I'm only just starting to learn about bad habits I've developed and principles I may have overlooked.
But still, as good as it is to dive in there and get your hands dirty, you have to, have to get a basic idea of what LaTeX is and how it works or you'll probably continue to have a pretty miserable time. It's no wonder you don't like it and everything seems arcane and difficult and a complete pain in the posterior to you!
Also, in setbuilder notations as this I'd add spacing as in${,x mid x text{ is positive and even},}$
– Hagen von Eitzen
Jul 1 '15 at 9:46
Sorry @MarcvanDongen, didn't realise. If nothing else, it demonstrates quite nicely something I overlooked because I never read about it, because I just assumed I knew how to do it, because of the "dive right in" approach I took :P
– Au101
Jul 1 '15 at 22:02
add a comment |
To answer your specific question:
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, 8dots}$
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
For really nice spacing, follow Hagen von Eitzen's advice and use:
${,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.
But, really, it's important that you gain an understanding of the basic operating principles of LaTeX before you go further and start worrying about how to do specific things; otherwise you're gonna be completely at sea and everything's gonna seem like black magic and nonsense. So I really recommend you have a little look through some basic introductions before diving right in there.
However I learned by doing - I learned by trying it out, I learned by using LaTeX and looking things up whenever I wanted to do something I didn't yet know how to do. That's a very fulfilling, very enjoyable and very practical way to learn - although there are massive holes in my knowledge and, because my approach was very light on theory, I'm only just starting to learn about bad habits I've developed and principles I may have overlooked.
But still, as good as it is to dive in there and get your hands dirty, you have to, have to get a basic idea of what LaTeX is and how it works or you'll probably continue to have a pretty miserable time. It's no wonder you don't like it and everything seems arcane and difficult and a complete pain in the posterior to you!
To answer your specific question:
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, 8dots}$
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
For really nice spacing, follow Hagen von Eitzen's advice and use:
${,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.
But, really, it's important that you gain an understanding of the basic operating principles of LaTeX before you go further and start worrying about how to do specific things; otherwise you're gonna be completely at sea and everything's gonna seem like black magic and nonsense. So I really recommend you have a little look through some basic introductions before diving right in there.
However I learned by doing - I learned by trying it out, I learned by using LaTeX and looking things up whenever I wanted to do something I didn't yet know how to do. That's a very fulfilling, very enjoyable and very practical way to learn - although there are massive holes in my knowledge and, because my approach was very light on theory, I'm only just starting to learn about bad habits I've developed and principles I may have overlooked.
But still, as good as it is to dive in there and get your hands dirty, you have to, have to get a basic idea of what LaTeX is and how it works or you'll probably continue to have a pretty miserable time. It's no wonder you don't like it and everything seems arcane and difficult and a complete pain in the posterior to you!
edited Apr 13 '17 at 12:34
Community♦
1
1
answered Jul 1 '15 at 4:14
Au101Au101
7,16832254
7,16832254
Also, in setbuilder notations as this I'd add spacing as in${,x mid x text{ is positive and even},}$
– Hagen von Eitzen
Jul 1 '15 at 9:46
Sorry @MarcvanDongen, didn't realise. If nothing else, it demonstrates quite nicely something I overlooked because I never read about it, because I just assumed I knew how to do it, because of the "dive right in" approach I took :P
– Au101
Jul 1 '15 at 22:02
add a comment |
Also, in setbuilder notations as this I'd add spacing as in${,x mid x text{ is positive and even},}$
– Hagen von Eitzen
Jul 1 '15 at 9:46
Sorry @MarcvanDongen, didn't realise. If nothing else, it demonstrates quite nicely something I overlooked because I never read about it, because I just assumed I knew how to do it, because of the "dive right in" approach I took :P
– Au101
Jul 1 '15 at 22:02
Also, in setbuilder notations as this I'd add spacing as in
${,x mid x text{ is positive and even},}$
– Hagen von Eitzen
Jul 1 '15 at 9:46
Also, in setbuilder notations as this I'd add spacing as in
${,x mid x text{ is positive and even},}$
– Hagen von Eitzen
Jul 1 '15 at 9:46
Sorry @MarcvanDongen, didn't realise. If nothing else, it demonstrates quite nicely something I overlooked because I never read about it, because I just assumed I knew how to do it, because of the "dive right in" approach I took :P
– Au101
Jul 1 '15 at 22:02
Sorry @MarcvanDongen, didn't realise. If nothing else, it demonstrates quite nicely something I overlooked because I never read about it, because I just assumed I knew how to do it, because of the "dive right in" approach I took :P
– Au101
Jul 1 '15 at 22:02
add a comment |
LaTeX puts at your disposal the package braket
that helps you creating beautiful sets, kets and bras for the Dirac notation. In particular
set{x, mid x<2}
ket{psi}
bra{phi}
do the job as simple as that as shown below:
Let $A=set{xmid psi(x)>0}$; also, given
$ket{psi}inmathcal{H}$, then $psi(x)coloneqqbraket{x|psi}$.
1
Well, thesets
command frombraket
is definitely useful, but the question has nothing to do withbra
andket
from Dirac notation in Hilbert space. I suggest to elaborate on your answer.
– Christian Hupfer
Jul 1 '15 at 21:58
To make your question useful and self contained, please make a MWE and also show the output itself.
– Nasser
Jul 1 '15 at 22:10
Is it not possible to display LaTeX outputs as per LaTeX tags in this section? I have tried (and failed) to display a working example.
– gented
Jul 1 '15 at 22:15
One saves a screen dump into a jpeg and crops it. Then, one can attach the image to their answer by clicking the icon that looks like a picture.
– Steven B. Segletes
Jul 2 '15 at 1:46
Thank you, I have done so. However, is there no way to show LaTeX markup inside the text? Other sections of the site do.
– gented
Jul 2 '15 at 20:15
|
show 3 more comments
LaTeX puts at your disposal the package braket
that helps you creating beautiful sets, kets and bras for the Dirac notation. In particular
set{x, mid x<2}
ket{psi}
bra{phi}
do the job as simple as that as shown below:
Let $A=set{xmid psi(x)>0}$; also, given
$ket{psi}inmathcal{H}$, then $psi(x)coloneqqbraket{x|psi}$.
1
Well, thesets
command frombraket
is definitely useful, but the question has nothing to do withbra
andket
from Dirac notation in Hilbert space. I suggest to elaborate on your answer.
– Christian Hupfer
Jul 1 '15 at 21:58
To make your question useful and self contained, please make a MWE and also show the output itself.
– Nasser
Jul 1 '15 at 22:10
Is it not possible to display LaTeX outputs as per LaTeX tags in this section? I have tried (and failed) to display a working example.
– gented
Jul 1 '15 at 22:15
One saves a screen dump into a jpeg and crops it. Then, one can attach the image to their answer by clicking the icon that looks like a picture.
– Steven B. Segletes
Jul 2 '15 at 1:46
Thank you, I have done so. However, is there no way to show LaTeX markup inside the text? Other sections of the site do.
– gented
Jul 2 '15 at 20:15
|
show 3 more comments
LaTeX puts at your disposal the package braket
that helps you creating beautiful sets, kets and bras for the Dirac notation. In particular
set{x, mid x<2}
ket{psi}
bra{phi}
do the job as simple as that as shown below:
Let $A=set{xmid psi(x)>0}$; also, given
$ket{psi}inmathcal{H}$, then $psi(x)coloneqqbraket{x|psi}$.
LaTeX puts at your disposal the package braket
that helps you creating beautiful sets, kets and bras for the Dirac notation. In particular
set{x, mid x<2}
ket{psi}
bra{phi}
do the job as simple as that as shown below:
Let $A=set{xmid psi(x)>0}$; also, given
$ket{psi}inmathcal{H}$, then $psi(x)coloneqqbraket{x|psi}$.
edited Jul 2 '15 at 20:14
answered Jul 1 '15 at 21:49
gentedgented
22418
22418
1
Well, thesets
command frombraket
is definitely useful, but the question has nothing to do withbra
andket
from Dirac notation in Hilbert space. I suggest to elaborate on your answer.
– Christian Hupfer
Jul 1 '15 at 21:58
To make your question useful and self contained, please make a MWE and also show the output itself.
– Nasser
Jul 1 '15 at 22:10
Is it not possible to display LaTeX outputs as per LaTeX tags in this section? I have tried (and failed) to display a working example.
– gented
Jul 1 '15 at 22:15
One saves a screen dump into a jpeg and crops it. Then, one can attach the image to their answer by clicking the icon that looks like a picture.
– Steven B. Segletes
Jul 2 '15 at 1:46
Thank you, I have done so. However, is there no way to show LaTeX markup inside the text? Other sections of the site do.
– gented
Jul 2 '15 at 20:15
|
show 3 more comments
1
Well, thesets
command frombraket
is definitely useful, but the question has nothing to do withbra
andket
from Dirac notation in Hilbert space. I suggest to elaborate on your answer.
– Christian Hupfer
Jul 1 '15 at 21:58
To make your question useful and self contained, please make a MWE and also show the output itself.
– Nasser
Jul 1 '15 at 22:10
Is it not possible to display LaTeX outputs as per LaTeX tags in this section? I have tried (and failed) to display a working example.
– gented
Jul 1 '15 at 22:15
One saves a screen dump into a jpeg and crops it. Then, one can attach the image to their answer by clicking the icon that looks like a picture.
– Steven B. Segletes
Jul 2 '15 at 1:46
Thank you, I have done so. However, is there no way to show LaTeX markup inside the text? Other sections of the site do.
– gented
Jul 2 '15 at 20:15
1
1
Well, the
sets
command from braket
is definitely useful, but the question has nothing to do with bra
and ket
from Dirac notation in Hilbert space. I suggest to elaborate on your answer.– Christian Hupfer
Jul 1 '15 at 21:58
Well, the
sets
command from braket
is definitely useful, but the question has nothing to do with bra
and ket
from Dirac notation in Hilbert space. I suggest to elaborate on your answer.– Christian Hupfer
Jul 1 '15 at 21:58
To make your question useful and self contained, please make a MWE and also show the output itself.
– Nasser
Jul 1 '15 at 22:10
To make your question useful and self contained, please make a MWE and also show the output itself.
– Nasser
Jul 1 '15 at 22:10
Is it not possible to display LaTeX outputs as per LaTeX tags in this section? I have tried (and failed) to display a working example.
– gented
Jul 1 '15 at 22:15
Is it not possible to display LaTeX outputs as per LaTeX tags in this section? I have tried (and failed) to display a working example.
– gented
Jul 1 '15 at 22:15
One saves a screen dump into a jpeg and crops it. Then, one can attach the image to their answer by clicking the icon that looks like a picture.
– Steven B. Segletes
Jul 2 '15 at 1:46
One saves a screen dump into a jpeg and crops it. Then, one can attach the image to their answer by clicking the icon that looks like a picture.
– Steven B. Segletes
Jul 2 '15 at 1:46
Thank you, I have done so. However, is there no way to show LaTeX markup inside the text? Other sections of the site do.
– gented
Jul 2 '15 at 20:15
Thank you, I have done so. However, is there no way to show LaTeX markup inside the text? Other sections of the site do.
– gented
Jul 2 '15 at 20:15
|
show 3 more comments
Here's an option with mathtools
package. I show here the different possible sizes and usage.
documentclass{scrartcl}
usepackage{mathtools}
DeclarePairedDelimiterXset[1]lbracerbrace{defgiven{;delimsizevert;}#1}
begin{document}
$set{ x given x > 0 }$
$set[big]{ x given x > 0 }$
$set[Big]{ x given x > 0 }$
$set[bigg]{ x given x > 0 }$
$set[Bigg]{ x given x > 0 }$
$set*{ x given x > 0 rule{0cm}{2cm} }$ % rule is just here so you can see that it autostretches
end{document}
If you prefer to use set{ x | x > 0 }
rather than set{ x given x > 0 }
you can do
DeclarePairedDelimiterXset[1]lbracerbrace{setaux#1}
defsetaux#1|{#1;delimsizevert;}
To the pro users: I would welcome some help with the checking for a|
inside the argument in the second option. I believe it has something to do with som sort ofdefsetaux#1|#2|#3endsetaux{ifrelaxdetokenize{#2}relax #1 else #1 ;delimsizevert; #2 fi}
and call it withsetaux #1||endsetaux
. But I'm not certain (it probably has an error).
– Manuel
Jul 1 '15 at 22:08
Manuel — looks about right to me:)
– Will Robertson
Jul 2 '15 at 1:19
add a comment |
Here's an option with mathtools
package. I show here the different possible sizes and usage.
documentclass{scrartcl}
usepackage{mathtools}
DeclarePairedDelimiterXset[1]lbracerbrace{defgiven{;delimsizevert;}#1}
begin{document}
$set{ x given x > 0 }$
$set[big]{ x given x > 0 }$
$set[Big]{ x given x > 0 }$
$set[bigg]{ x given x > 0 }$
$set[Bigg]{ x given x > 0 }$
$set*{ x given x > 0 rule{0cm}{2cm} }$ % rule is just here so you can see that it autostretches
end{document}
If you prefer to use set{ x | x > 0 }
rather than set{ x given x > 0 }
you can do
DeclarePairedDelimiterXset[1]lbracerbrace{setaux#1}
defsetaux#1|{#1;delimsizevert;}
To the pro users: I would welcome some help with the checking for a|
inside the argument in the second option. I believe it has something to do with som sort ofdefsetaux#1|#2|#3endsetaux{ifrelaxdetokenize{#2}relax #1 else #1 ;delimsizevert; #2 fi}
and call it withsetaux #1||endsetaux
. But I'm not certain (it probably has an error).
– Manuel
Jul 1 '15 at 22:08
Manuel — looks about right to me:)
– Will Robertson
Jul 2 '15 at 1:19
add a comment |
Here's an option with mathtools
package. I show here the different possible sizes and usage.
documentclass{scrartcl}
usepackage{mathtools}
DeclarePairedDelimiterXset[1]lbracerbrace{defgiven{;delimsizevert;}#1}
begin{document}
$set{ x given x > 0 }$
$set[big]{ x given x > 0 }$
$set[Big]{ x given x > 0 }$
$set[bigg]{ x given x > 0 }$
$set[Bigg]{ x given x > 0 }$
$set*{ x given x > 0 rule{0cm}{2cm} }$ % rule is just here so you can see that it autostretches
end{document}
If you prefer to use set{ x | x > 0 }
rather than set{ x given x > 0 }
you can do
DeclarePairedDelimiterXset[1]lbracerbrace{setaux#1}
defsetaux#1|{#1;delimsizevert;}
Here's an option with mathtools
package. I show here the different possible sizes and usage.
documentclass{scrartcl}
usepackage{mathtools}
DeclarePairedDelimiterXset[1]lbracerbrace{defgiven{;delimsizevert;}#1}
begin{document}
$set{ x given x > 0 }$
$set[big]{ x given x > 0 }$
$set[Big]{ x given x > 0 }$
$set[bigg]{ x given x > 0 }$
$set[Bigg]{ x given x > 0 }$
$set*{ x given x > 0 rule{0cm}{2cm} }$ % rule is just here so you can see that it autostretches
end{document}
If you prefer to use set{ x | x > 0 }
rather than set{ x given x > 0 }
you can do
DeclarePairedDelimiterXset[1]lbracerbrace{setaux#1}
defsetaux#1|{#1;delimsizevert;}
answered Jul 1 '15 at 21:59
ManuelManuel
21.5k846108
21.5k846108
To the pro users: I would welcome some help with the checking for a|
inside the argument in the second option. I believe it has something to do with som sort ofdefsetaux#1|#2|#3endsetaux{ifrelaxdetokenize{#2}relax #1 else #1 ;delimsizevert; #2 fi}
and call it withsetaux #1||endsetaux
. But I'm not certain (it probably has an error).
– Manuel
Jul 1 '15 at 22:08
Manuel — looks about right to me:)
– Will Robertson
Jul 2 '15 at 1:19
add a comment |
To the pro users: I would welcome some help with the checking for a|
inside the argument in the second option. I believe it has something to do with som sort ofdefsetaux#1|#2|#3endsetaux{ifrelaxdetokenize{#2}relax #1 else #1 ;delimsizevert; #2 fi}
and call it withsetaux #1||endsetaux
. But I'm not certain (it probably has an error).
– Manuel
Jul 1 '15 at 22:08
Manuel — looks about right to me:)
– Will Robertson
Jul 2 '15 at 1:19
To the pro users: I would welcome some help with the checking for a
|
inside the argument in the second option. I believe it has something to do with som sort of defsetaux#1|#2|#3endsetaux{ifrelaxdetokenize{#2}relax #1 else #1 ;delimsizevert; #2 fi}
and call it with setaux #1||endsetaux
. But I'm not certain (it probably has an error).– Manuel
Jul 1 '15 at 22:08
To the pro users: I would welcome some help with the checking for a
|
inside the argument in the second option. I believe it has something to do with som sort of defsetaux#1|#2|#3endsetaux{ifrelaxdetokenize{#2}relax #1 else #1 ;delimsizevert; #2 fi}
and call it with setaux #1||endsetaux
. But I'm not certain (it probably has an error).– Manuel
Jul 1 '15 at 22:08
Manuel — looks about right to me
:)
– Will Robertson
Jul 2 '15 at 1:19
Manuel — looks about right to me
:)
– Will Robertson
Jul 2 '15 at 1:19
add a comment |
I defined a new command set
based on xparse
package. The result is nice-looking.
documentclass{article}
usepackage{xparse}
NewDocumentCommand{set}{o m}{%
% <code>
IfNoValueTF{#1}
{{#2}}
{{#1 mid #2}}%
% <code>
}
begin{document}
$set{x_1, dots}$ or ${set[x in X]{phi(x)}}$
end{document}
1
I edited your answer to make it more like an answer (with a complete and compilable code as well as an image of the result). If you don't like it, be free to roll back to the original version.
– JouleV
Feb 27 at 8:18
add a comment |
I defined a new command set
based on xparse
package. The result is nice-looking.
documentclass{article}
usepackage{xparse}
NewDocumentCommand{set}{o m}{%
% <code>
IfNoValueTF{#1}
{{#2}}
{{#1 mid #2}}%
% <code>
}
begin{document}
$set{x_1, dots}$ or ${set[x in X]{phi(x)}}$
end{document}
1
I edited your answer to make it more like an answer (with a complete and compilable code as well as an image of the result). If you don't like it, be free to roll back to the original version.
– JouleV
Feb 27 at 8:18
add a comment |
I defined a new command set
based on xparse
package. The result is nice-looking.
documentclass{article}
usepackage{xparse}
NewDocumentCommand{set}{o m}{%
% <code>
IfNoValueTF{#1}
{{#2}}
{{#1 mid #2}}%
% <code>
}
begin{document}
$set{x_1, dots}$ or ${set[x in X]{phi(x)}}$
end{document}
I defined a new command set
based on xparse
package. The result is nice-looking.
documentclass{article}
usepackage{xparse}
NewDocumentCommand{set}{o m}{%
% <code>
IfNoValueTF{#1}
{{#2}}
{{#1 mid #2}}%
% <code>
}
begin{document}
$set{x_1, dots}$ or ${set[x in X]{phi(x)}}$
end{document}
edited Feb 27 at 8:17
JouleV
4,91111139
4,91111139
answered Feb 27 at 8:10
Jens WagemakerJens Wagemaker
1206
1206
1
I edited your answer to make it more like an answer (with a complete and compilable code as well as an image of the result). If you don't like it, be free to roll back to the original version.
– JouleV
Feb 27 at 8:18
add a comment |
1
I edited your answer to make it more like an answer (with a complete and compilable code as well as an image of the result). If you don't like it, be free to roll back to the original version.
– JouleV
Feb 27 at 8:18
1
1
I edited your answer to make it more like an answer (with a complete and compilable code as well as an image of the result). If you don't like it, be free to roll back to the original version.
– JouleV
Feb 27 at 8:18
I edited your answer to make it more like an answer (with a complete and compilable code as well as an image of the result). If you don't like it, be free to roll back to the original version.
– JouleV
Feb 27 at 8:18
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f253077%2fhow-do-you-create-a-set-in-latex%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Welcome! This has nothing to do with
latex3
so I will edit the tags in a moment. However, please try${thing 1, thing 2, thing 3}$
.– cfr
Jul 1 '15 at 3:26
2
I'd recommend Kopka and Daly's A Guide to LaTeX. I realise that recommending books is a bit old-fashioned but I think it makes this kind of thing a lot easier, to be honest. All the basics covered in an order which makes sense and ensures that you have a sense of both the big picture and the details. The other thing is to make sure you have a good editor. Most editors will help you out with this kind of thing - especially with the code for symbols.
– cfr
Jul 1 '15 at 3:31
1
Welcome from me as well! My friend, it's no wonder you're not getting on with LaTeX if you haven't - haven't been taken through the basics (whether by a person, or a book). Myself, I actually got started with the wikibooks LaTeX manual (en.wikibooks.org/wiki/LaTeX), which I think is a very good place to start, but there are quite possibly better resources out there - @cfr's seem good. But if you don't understand the principles of LaTeX, you're not going to have an easy time with it. Not that learning by doing isn't the way to go - it is, but you have to understand 1st principles.
– Au101
Jul 1 '15 at 3:41
1
Have you seen What are good learning resources for a LaTeX beginner?
– clemens
Jul 1 '15 at 7:49
2
The general answers that help you learn LaTeX are good ones. There's an answer to your particular question here: tex.stackexchange.com/questions/209863/…
– Ethan Bolker
Jul 1 '15 at 16:09