My favorite LaTeX packages for writing beautiful math documents

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video i'm going to show you how to  supercharge your latex skills now if you're   a complete beginner in latex don't worry i've got  you completely covered down in the description i   have my three previous videos that are going to  take you from being a complete beginner all the   way to an expert at latex and broadly speaking  latex is just this markup language that allows   you to write beautiful documents for math and  many other stem fields and beyond what i'm going   to do in this video is talk about packages  packages are these things that you can add   to latex that give you vastly more functionality  and let you do all sorts of really cool things   with your math documents now to work in latex  you need a latex editor and i'm going to be using   Overleaf Overleaf is an entirely cloud-based latex  editor they're really awesome i've been using them   for a number of years both personally and with my  students and i'm actually very proud to say that   they are sponsoring this particular video on latex  so my thanks to Overleaf with that said and done   let's go into the video what i have here is the  beginning of a document on the left hand side i've   written a bunch of code and basically all i've  done is labeled a bunch of different sections   which is some of the things that i'm going to talk  about in this video and then on the right hand   side here i have the output of what is primarily  my empty document right now just this long list   of different section titles now the first thing i  want to do is make it so that you can check this   out as i fill things out so i'm going to come  up here to the share button it's really nice   overleaf gets you the ability to send a link to  anybody i'm just going to copy that link and i'm   actually going to put it down in the description  so if you just want to have that saved in case   you want to remember what we're talking about  for the future you can just open this document   right up in overleaf or copy it to whatever latex  editor you so choose let's look a little bit more   closely about what i have before first i'm going  to look at the preamble and the preamble is the   stuff before the begin document i don't have very  much i have mainly a series of packages and these   are all the packages i've actually used in my  previous videos amsmath amsfonts and amsthm i   always add those to any latex document that  i'm doing that has anything to do with math   graphicx lets me include images geometry lets me  do margins and lipsum is this nice thing to be   able to generate random text just for testing out  different features i've talked about all of those   in my previous videos so i just copy them here  and we're going to do new ones for this video   okay let's go in order the first package i want  to talk about is hyperref so i'm going to come   here and i'm going to start a new line i'm going  to go use package and as you can see with Overleaf   they start to populate what the possible answer is  let's just type in an h and you could already see   right there if you forget the name hyper reference  it automatically completes it that's the package   i want to do now hyper ref does two major things  first is it allows me to do links external to my   document for example if i go down here to the  section on hyper ref and let me suppose that   i want to link to my youtube channel so the way  i'm going to do this is i want the text youtube   channel to be when you click that text then you're  going to go off and you're going to go to the   youtube channel so i'm going to come here and i  go backslash and then it's href that's the command   and this is going to take two different inputs so  i do squiggley braces to decide what the input is   the second input that i've selected here  is the text that is going to be linked   in the first set of braces i want to type  what it is going to be linking to so let's   do http://www.youtube.com/drtreforbazett and now  when i go down here to this section it says i want   to link to my youtube channel and you notice that  as my most goes over it it becomes a link and then   if i click this let's see what happens well i just  get to my youtube channel the main problem though   is that you wouldn't actually know to click on  this youtube channel because it just appears like   black text so what i really need to do is start  changing some of the settings of how links are   actually going to work so what i'm going to do is  adjust some settings in the use package hyperref   i'm going to copy and paste a few common settings  that i use here the first thing you'll notice here   is that now this link appears red so what's going  on in the way i set it up so i did \hypersetup and   then i put some parameters the first one is i set  color links to be true which just means that links   are going to be a color the second thing is well  there's going to be two types of links in a moment   the one i'm talking about right now is urls so i  set url color to be red and that's why it was red   it's more common perhaps to use blue  but i just chose red to be different   and then there's another one here that says  link color and that's equal to blue now   what's happened here what is a link well a link in  hyperref is an internal link within the document   so if i scroll back up previously my contents  were sort of dumb if you just you had the list   of them but you didn't know where they're going to  go so maybe you go to the right-hand side and say   well they're all on page two because my doctor's  not very long but now if i click say hyperref it's   blue for an internal reference and it goes right  to the spot and then i can click the red youtube   channel for an external reference out of it so  you can customize the colors of either of those   but all the things that you might do whether it's  going to be footnotes whether it's going to be   references all of those are going to get different  colors and you can really come in here and specify   exactly what you want to do now a lot of these  packages i'm going to talk about the real devil   is in the details and so you really need to check  out the full documentation to see like what is   possible and so down in the description i'm also  going to link to the documentation for many of the   packages that i'm going to use so you can see like  all of the options i'm just going to show a few   there is one other one i'm going to do right now  and that's this one that says pdf title is equal   to "how to write a thesis" the idea here is that  hyperref controls many of the aspects of how the   eventual pdf that you will create is going to  look so for example if i come here and download   the pdf this is like the thing i might actually  submit let's open it and see what it looks like   you'll notice that up at the top here it says  how to write a thesis it's like any pdf reader   has this internal title and i've specified  that that title is "how to write a thesis"   and i used hyperref to do that all right moving  right along the next package i'm going to use   so let's do another use package is called fancy  and then verbatim so fancyvrb and this is going   to allow me to do blocks of things like code  it allows you to write something verbatim so   what i'm going to do down here is i'm going to  \begin and i'm going to begin a verbatim section   and again overleaf pops up the options i'm going  to use the capitalized one which is associated   this particular one and i'm going to just go and  control paste some random block of code it doesn't   matter what this code is but look what happens so  i'm going to click compile and what you can see is   i have just a copy and paste of all of this code  if i hadn't put that in the verbatim environment   then latex would have tried to execute that code  it doesn't have to be latex code you can just put   anything you want you've got your python code or  whatever else it's going to be you put that in a   verbatim environment but what i really like about  fancy verbatim environment is now you can control   the way these things are displayed the way i do  this is that if i go to the \begin{Verbatim} i'm   going to put things inside of square brackets  which is sort of telling latex about different   parameters you're going to do the first thing  i'm going to do is i'm going to do numbers=left   and and basically what i want to do with  numbers=left is i want to put a list of   numbers on the left hand side kind of like how  you normally enumerate the the different lines   of some block of code the other thing i'm going  to do is i can go frame=single now i see that   i've created an error doing this and overleaf will  tell me when i make error so let me go and click   and figure out this is and try to figure it and  what it is is it's telling me it's right in the   spot of that particular code here and i actually  now notice what it is i said framed but actually   the documentation is going to tell me that it's  supposed to be frame so now i'm going to recompile   it this without that little typo and it looks  really really nice you've got all these numbers   down here so that's what i did with the the  numbers on the left hand side and i just get this   nice little box by the way uh Overleaf trick is if  you just come up here you can full screen just the   output so you can see exactly what it looks like  and you're like okay that makes sense to me and   then you can click back here to go to the split  screen on my small little 1080p laptop everything   sort of gets a little bit bunched together but on  a larger screen you might want to be split screen   all the time it's sort of up to you another thing  that you can do is they call it format command   form com is equal to uh color and maybe i'll make  that color just be the color red so if i do this   then everything should appear red so the point is  this package allows you to really control the look   and feel of any code block that you want to put  in verbatim all right what are we going to do next   fancy header i really like this one so we're going  to go back up to the top here i have used package   fancy verbatim \usepackage and it's going to be  fancyhdr there it is thank you Overleaf and this   is going to allow me to do really funky headers  and footers because headers and footers are things   you're probably going to have over the entirety of  your document you actually put all the information   of them up here in the preamble so the first thing  i do is something called pagestyle and i'm going   to write \pagestyle{fancy} as opposed to plain  this is going to let me leverage the power of the   fancy header package and now inside of this i  have headers and footers but in each header and   footer the header is going to have a left center  and a right and likewise for the footer so what   i want to do i'm going to go \lhead this is going  to be representing the left header and i'm going   to say how about this trefor's awesome latex  guide something like this i'm also going to go   and do \rhead for right header and how about this  sponsored by Overleaf uh what else do i want to do   maybe on the bottom i'm going to go \cfoot so left  right and c is for center this is now a footer   and i'm going to do how about this uh \thepage.  \thepage tells me the page number that i'm on   okay let's go and compile this and and see what  we get expanding out what i now see is that on the   top i have this header that says Trefor's awesome  latex guide sponsored by Overleaf and then down on   the bottom i have the page just gives me the page  number there's one other package that i often use   together with fancyhdr i would actually put it  into the same thing it doesn't matter whether you   list all the usepackage one over another or just  do one call with them separated by commas this is   called last page it's a really small package it  just spits out with the last pages and the reason   we might want to do this is in the footer how  about this i will write this page \thepage will   give me the the page number and then i'm going to  write of and the way i try to reference the last   page of the document is i go \pageref{LastPage}  and this required that lastpage package to be   able to do it now let's go and see what happens  when i run this you see how now it says page   three of three well i actually need to go and put  an extra space here so i'm gonna do backslash then   i'll leave the space and that if i redo it should  now give page three of three it gives this very   nice thing and then you have page one of three  two of three three of three and so on this is the   type of thing that latex is extremely powerful  on you're making a really long thesis document   you're not wanting to write these things every  page where they might change you want it just   to be numbered automatically and that's what's  happening it always figures out what the last page   is no matter the length of your document notice  that the three here is in blue because because of   the hyperref this is interpreted as actually a  link and you can click it and go directly to that   last page if you so wish now one thing is going to  happen if i scroll up okay this is the third page   and it has the header and the footer but notice  the second page doesn't and the top page doesn't   why are there no headers here well the argument  is that if i look at the type of document this   is which i have decided this is a report this  is something that's got title pages it's got   table of contents and it's got the first page of  a chapter very often you don't want your headers   to appear like right at the start of a new chapter  and so it's very reasonable and basically what's   happening is that the report class when it sees  that you've got a new chapter there it interprets   it as having a plain header style opposed to this  fancy header style that we were trying to impose   so if i wanted to overrule that what could i  do now the thing i'm going to tell you i want   you to use with a little bit of caution  i'm going to show you one of the truly   powerful packages i'm going to copy and paste  everything this package is called etoolbox   and if you're the type of person who's writing  your own packages etoolbox is extremely useful   etoolbox allows you to do things like go  in and change what exactly a report even   is and so i've added this long command that's  just basically going to fix this exact issue   and basically what it's going to do is it's going  to go into the command for chapter and it's going   to change it from having a page style of plain to  a page style of fancy the exact syntax let's not   worry about but if i add this little fancy patch  then what do i get i get even on the table of   contents i'm going to have a header even down here  on the the sort of first page of a new chapter   i'm going to get a header all right next one on  the list is github this actually isn't a package   it's just one of the really cool features of  overleaf that i really wanted to tell you about so   here's what i'm going to do i'm going to go back  up to the menu here and you notice some various   ways that you can sync for example a lot of  people use dropbox you can sync with dropbox   but i'm going to sync with github and github has a  lot of really powerful features overleaf actually   uses many of them like having a bunch of different  features and being able to track your changes and   to be able to accept or reject a change all of  that can be done within overly but if you want   to work with somebody who's either not using  overleaf or you're really invested in github   you might want to do that so what i'm going to do  is i'm going to push to overleaf a commit of my   changes that i've made here and if i now open  tbazett youtube packages you can go to github   yourself this is public you can check it out  at my tbazett/youtubepackages uh github and now   you can go and check out the exact same document  that we've been working with inside of overleaf   pretty cool stuff okay that's all i got to say  about github next up fancy chapters this one   is a little bit vain but if i look at the  way i made a chapter remember how i made   one chapter where is it yes right here is the  chapter useful packages and it just automatically   if you don't do anything goes chapter one and puts  the title in but maybe you wanna make it look just   a little bit nicer well that's entirely reasonable  so what i'm gonna do here is i'm gonna go to a new   used package and what i'm gonna do is one called  fncychap i'm going to copy and paste down here   the various options that you can include in  this one basically fancy chap is one of many   different packages out there to do fancy looking  chapters this is definitely not the only option   but what it accepts is a parameter and you  can put in one of these funky looking names   and each of them has their own sort of unique  style so one i really like is glenn of all things   so i'm going to use the package fncychap with  the parameter [glenn] specified let's see how   this chapter one is going to turn out if i expand  here to go to full screen mode you get this nice   little box and put the titles over there it just  looks nice next up is color so i need to add a   new package for this i'm going to go and do use  package and i actually like the one that's called   xcolor so there's a different there's a few  different sort of color packages out there   but this is the one that i like now my document's  getting a bit long and i want to go to the right   section so what i'm actually going to do is expand  the file menu here you'll see an overleaf that   there's this uh nice sort of listing of all the  sections i'm going to click the color section   and it's going to take me directly to where i want  to be able to go just makes things a little bit   easier the way i'm going to do this is that let's  type some text let's make this be red and what i'm   actually going to do is i want only the this to be  red and the way i do this is i wrap it around in   sort of braces to make it a section so that this  is inside of a section and then i go \color{red}   and basically what's happening here is i've made  this section that includes the word this and   i've specified that for that little section  it's going to have the command \color{red}   and what do we get let's make this be red you can  also do stuff outside of it so if i go for example   \color{blue} and this text will be blue until  i change to a new color like how about this one   uh \color{black} and then i'll just type black  and the idea here is that anything you have   after one color turns the entire rest of the  document if it's not embraces to that color   until i change it once again and so i've got some  red i've got some blue and i've got some black   all right next one t color box also related  to color but this is going to make things look   really really nice so i'm going to add this new  package and i'm actually going to add two here   so the first one i'm going to do is called tikz  and then the next one i'm going to do is tcolorbox   basically tcolorbox is what i want to talk about  but it requires this other package pixie i'm   actually planning to do an entire video just about  tikz so i'm going to talk about it more later but   tikz allows you to make beautiful mathematical  drawings and so it's its own entire thing and   it's really powerful i'm going to just paste some  some random code that i have just from something   else that i was working on earlier and what do i  get well i get this kind of cool picture with a   bunch of different arrows so we're going to cover  exactly how to do tikz in another video not this   one what i'm going to be talking about is this  tcolorbox and so i'm going to show how to use that   let's get rid of all of that beautiful uh images  so what i want to do is take some text like   this is a tcolorbox and i want to frame it i'm  going to put it in between \begin{tcolorbox}and   uh \end{tcolorbox} if i run this look at how  pretty it's gonna be what i'm gonna get is   this nice little box that surrounds it everything  defaults to sort of the gray and the blocks and it   really just sort of emphasizes this particular  piece of code so whenever i'm writing documents   particularly ones for students so they're maybe  not like really formal mathematical documents but   i just want them to be readable and enjoyable  i love tcolorbox we've been able to do this   i'm going to do another one so begin tcolor and  i've already seen it highlighted in overleaf so   i'm going to uh just hit enter and it will expand  it and i'm going to say this is a tcolorbox with   a heading this is kind of cool now what i'm going  to do is i'm going to add a few different things   so i've copied and pasted what i'm going to  add i'm going to add a few things from the   right hand side i've got my title is called  my nice heading let's see what it does first   so after i compile this you're going to see that  i get this nice little heading here it looks like   a different kind of tcolorblock so the first thing  is there's a title and there it is in the options   title is equal to my nice heading then there's two  basic colors that i've specified so first of all   there's the color of the background and then  there's the color of the frame so you sort of see   this dark red is the frame and the sort of light  pink is the background i specify both of those   colors and so what did i set them was this code  here where it goes red!5!white is basically saying   it's five percent red and ninety-five percent  white so for the background i add just basically   a little bit of red how much red five percent and  then the rest white for the frame notice what i've   done i've gone red and then between my exclamation  points i've put the number 50. so this is 50 red   50 black that gives me this really nice dark one  there's many other ways to represent these colors   but this is just sort of a nice and easy way to  try and understand how to make these nice colors   i want to show you one other thing that tea color  boss can do because it's really really useful for   theorems i've actually talked in a previous video  in the latex series a lot about how to make like   theorems and definitions and proofs environments  and how to do that i'll show you how to do it now   with tea color blocks to make them just sort of  look visually very nice i actually have to make   one change to the way i included these packages i  want to have them on separate lines here i'll show   you why in a moment the reason is i want to send  tcolorbox a parameter that didn't apply for tikz   i want to send it the most parameter that's going  to include most of the functionality and then what   i want to do is make a new theme environment  and this i'm going to use a new tcolorblock   theorem environment in other words it's going to  be newtcbtheorem and it has the same basic syntax   that making a new theorem did before the way i'm  going to call it in shorthand is just going to   be theo and then the way it's going to display  it here is as a theorem and then it's going to   deal with all the different numbers there's a  bunch of parameters you might want to deal with   but let's go and see how it looks and what am i  going to do i'm going to go and do a \begin{theo}   that was the name for what i had specified this  to be and theorems accept a couple different   parameters the first one is going to be the title  of the theorem let's call this like and subscribe   and the second is going to be a shorthand  reference so i can refer to it how about like   likesub this is not going to be seen by users and  then i can just write out whatever my theorem is   for every person uh x uh x should like  and subscribe i mean this theorem can be   stated without proof and if i come here and  go to my full screen i can see what my nice   little theorem environments and other tcolorboxes  are going to do and this is going to keep track of   numbering i can refer to them all those powerful  things i could do with theorems previously   we can do akin but now they look nice all right  three different things to go the first is SI units   SI units is kind of funny so imagine i'm gonna  go and try to write something like oh i don't   know five kilograms meters per second squared  something like this i'm going to say 5 newtons   if i run that then what i have is everything is  like italicized and blurred together it doesn't   look like the standard way you're supposed  to refer to things in si units and there's   actually a way to do a little bit of a hack here  so i could instead do the following i could do   5 and then i'm going to put a nice space there and  then i'm going to do \mathrm this stands for math   roman it's like putting things back into romans  so even though i'm sort of in a math environment i   can come here and write the kilograms and then i'm  gonna do the same thing \mathrm uh times meters   excuse me meters and then i'm going to divide by  \mathrm and i'm going to raise that to the power   of 2. that was frustrating and if you're doing  this a lot you get a little bit tired but at least   it's formated correctly five kilograms meters  per second this is the way at least it's supposed   to display and so the point about the si units  package is that it allows you to do the proper way   to display si units just a little bit faster but  let me show you how i'll scroll back up to the top   here i'm going to use uh another package which is  siunitx and then it's also got an x in them a lot   of these packages have an x at the end of them  i do want to note by the way i'm sort of like   randomly listing these these packages as i keep on  adding them and adding spaces between them this is   usually not how you do it usually just put all the  packages all in one spot nicely up on the top here   don't leave as much space as i'm doing here kind  of a i do as i say not as i do type of thing but   now that i have this let's just see how  it's going to work out i'm going to do   five and then i do \si{} and now i can just refer  to things like i can do kilograms that's the way i   do kilograms and then i'll put a dot here and i'll  do meters and then i will do s to the power of two   and that's it if i run this that is going to give  me well exactly the same thing i had before it   shouldn't change i mean there it is 5 kilograms  meters per second squared is 5 newtons it looks   exactly same but but it took me way less effort to  write next up is set space and for set space well   i'm going to begin with a generic block of text  i'm going to do lip sum and i'm going to go and do   1 up to 10 something like this lipsum i had  included that package earlier it just gives   this random block of latin text and it's literally  only there we only know about it just so that you   can see what a bunch of text looks like it's  an easy way to generate it without having to   type something yourself if i go to full screen  you can look at this and you might think i like   the spacing i don't like the spacing i might want  to tweak it i might have to submit a thesis that   requires a certain standard of spacing and this  isn't it so i'm going to go all the way back up   and i'm going to use another package and this was  one is called set space and it allows multiple   things you could have double spacing single  spacing one half spacing is one i like a lot   so i'm gonna type \onehalfspacing and notice how  everything right now is quite clustered together   i hit this i run that and what am i gonna get  everything has nicely spaced out a little bit   it just looks a little better i could do double  spacing if i wanted it even more spaced out for   this before i go to my next one i'm going to come  up here to the review button and i'm going to turn   track changes to on and just uh we'll come back  to that in just a moment so i'm going to do once   again a used package and what i'm going to do is  glossaries-extra is the name of this particular   package i'm going to as a parameter also add  in acronym because i don't really like using   acronyms and so i need to put this in here to get  this functionality i've now come in here and i've   added a few extra lines here so what's going on  the first of them is just standard i'm going to   do this set abbreviation style and whenever i have  an acronym i want it to the very first time i use   it to display my acronym in a long form and then  thereafter to display it in a short form so i set   set abbreviation style acronym it goes long short  so the first time is long then afterwards it's   short and then i want to make a new acronym and  what i've done here is i've made a new acronym and   it's got three different inputs the first is the  input to which i internally refer to it so anytime   i write dtb it's going to give this acronym  capitalize dtb is how it's going to display   for the reader in its short form and then  in the third set of braces i put the long   version of the acronym Dr Trefor Bazett dtb  okay i'm just being a little bit vain here   so now when i go back to the bottom here and  then what i do here is uh i want to say and i do   \gls{} for glossary and then i need to input  the name of it remember the specific acronym   i'm using was dtb uh to be long the first time and  short the second and let me do it a second time   \gls{dtb}just so that we can see it once long  and one short so i've called the same thing both   time i said \gls{dtb} both times but notice what  happens i want to say Dr Trefor Bazettand then it   puts the short form is in practice the first time  to be long the first time and short the second   i have a little bit of a warning here i know what  the reason is because well i've introduced this   acronym i haven't made a glossary of the acronyms  yet so i'm going to go down to the very bottom of   my document right beside the end document and  i'm going to put in print glossary and the type   is going to be it's an acronym type so this is  the command for that and what that is now done   is i have a new section at the very bottom  which is a basically a chapter on acronyms   and it lists the one acronym that i have so if  i was in lots of different acronyms i love using   acronyms then i could have this nice list and you  could click on the link to go to the exact page   final thing i want to show remember i clicked  that track changes on let's expand what it is   now you can see how the the new change that i  just made i have the option to be like did i   like that did i not like that i'm going to accept  that and what it does here for all these spots   where i've come and made changes i can go up and  look at them all i'm like yes i want all of those   changes i am going to actually commit to them so  track change is just the final very nice overly   feature that just really levels up your ability  to make a lot of edits and then if something goes   wrong you can figure out exactly where it was  wrong and you can accept them or reject them   all right so that brings me to the end of  this video on packages in latex i really   much hope you enjoyed if you have any of your  own favorite packages absolutely leave them   down in the comments below i totally love to  see them there's so many great packages out   there and i don't know every single one of those  packages so tell me the ones that you're gonna use   definitely there's gonna be more videos coming up  in the latex series so i hope you check out those   give the video a like for the youtube algorithm  and we'll do some more math in the next video
Info
Channel: Dr. Trefor Bazett
Views: 196,908
Rating: undefined out of 5
Keywords: Solution, Example, math, latex tutorial, latex packages, best latex packages, verbatim, code, headers, footers, chapters, fancy, acronyms, glossary, SI units, Github integration, sync, overleaf, line spacing, latex links, latex url, hyperref, latex colors
Id: 331YxgOJUGw
Channel Id: undefined
Length: 28min 47sec (1727 seconds)
Published: Tue Nov 16 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.