LaTeX tutorial II

1,404
-1

Published on

The presentation of the 2nd session of the LaTeX course of the BiB.

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,404
On Slideshare
0
From Embeds
0
Number of Embeds
15
Actions
Shares
0
Downloads
42
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

LaTeX tutorial II

  1. 1. A Introduction to LTEX Session #2 Oriol Borrega Pedro Tiago Martins Universitat de Barcelona January 21, 2013Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 1 / 41
  2. 2. Outline1 A preamble: preambles Styling with style2 Listing the lists Itemizing stuff Enumerating stuff Defining stuff3 Floating elements Imagine images Why must there always be a table? Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 2 / 41
  3. 3. Before we begin. . .Before we begin. . . . . . remember your commands!documentclass[a4paper,12pt]{article}section{Your section name here}emph{some text here}begin{document}Lots of stuff in hereend{document} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 3 / 41
  4. 4. Before we begin. . .Before we begin. . . . . . remember your commands!documentclass[a4paper,12pt]{article}section{Your section name here}emph{some text here}begin{document}Lots of stuff in hereend{document} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 3 / 41
  5. 5. Before we begin. . .Before we begin. . . . . . remember your commands!documentclass[a4paper,12pt]{article}section{Your section name here}emph{some text here}begin{document}Lots of stuff in hereend{document} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 3 / 41
  6. 6. Before we begin. . .(and a brief side comment)Anything following a percent sign (%) will be ignored by the compiler.That’s very useful to put comments in your documents or to turn on/offcommands and lines of text. Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 4 / 41
  7. 7. A preamble: preamblesOutline1 A preamble: preambles Styling with style2 Listing the lists Itemizing stuff Enumerating stuff Defining stuff3 Floating elements Imagine images Why must there always be a table? Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 5 / 41
  8. 8. A preamble: preamblesAn example of a preambledocumentclass{article}usepackage[english,catalan]{babel}usepackage[ansinew]{inputenc}usepackage{geometry} %Allows to change layout settingsusepackage{enumerate} %Enables liststitle{The Denisova Hominin}author{Wikipedia}date{January 21st, 2013}parskip=5mmgeometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 6 / 41
  9. 9. A preamble: preamblesWhat is going on here? We are declaring the kind of document we want documentclass[a4paper,12pt]{article} A We are telling LTEX we will do some “special tricks” usepackage[english,catalan]{babel} usepackage[ansinew]{inputenc} usepackage{geometry} usepackage{enumerate} We are signing our document title {The Denisova hominin} author {N.E.Ander et al.} date {Just about today} We are changing the default layout of the document parskip=5mm geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 7 / 41
  10. 10. A preamble: preamblesWhat is going on here? We are declaring the kind of document we want documentclass[a4paper,12pt]{article} A We are telling LTEX we will do some “special tricks” usepackage[english,catalan]{babel} usepackage[ansinew]{inputenc} usepackage{geometry} usepackage{enumerate} We are signing our document title {The Denisova hominin} author {N.E.Ander et al.} date {Just about today} We are changing the default layout of the document parskip=5mm geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 7 / 41
  11. 11. A preamble: preamblesWhat is going on here? We are declaring the kind of document we want documentclass[a4paper,12pt]{article} A We are telling LTEX we will do some “special tricks” usepackage[english,catalan]{babel} usepackage[ansinew]{inputenc} usepackage{geometry} usepackage{enumerate} We are signing our document title {The Denisova hominin} author {N.E.Ander et al.} date {Just about today} We are changing the default layout of the document parskip=5mm geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 7 / 41
  12. 12. A preamble: preamblesWhat is going on here? We are declaring the kind of document we want documentclass[a4paper,12pt]{article} A We are telling LTEX we will do some “special tricks” usepackage[english,catalan]{babel} usepackage[ansinew]{inputenc} usepackage{geometry} usepackage{enumerate} We are signing our document title {The Denisova hominin} author {N.E.Ander et al.} date {Just about today} We are changing the default layout of the document parskip=5mm geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 7 / 41
  13. 13. A preamble: preamblesWhat is going on here? We are declaring the kind of document we want documentclass[a4paper,12pt]{article} A We are telling LTEX we will do some “special tricks” usepackage[english,catalan]{babel} usepackage[ansinew]{inputenc} usepackage{geometry} usepackage{enumerate} We are signing our document title {The Denisova hominin} author {N.E.Ander et al.} date {Just about today} We are changing the default layout of the document parskip=5mm geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 7 / 41
  14. 14. A preamble: preamblesWhat is going on here? We are declaring the kind of document we want documentclass[a4paper,12pt]{article} A We are telling LTEX we will do some “special tricks” usepackage[english,catalan]{babel} usepackage[ansinew]{inputenc} usepackage{geometry} usepackage{enumerate} We are signing our document title {The Denisova hominin} author {N.E.Ander et al.} date {Just about today} We are changing the default layout of the document parskip=5mm geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 7 / 41
  15. 15. A preamble: preamblesWhat is going on here? We are declaring the kind of document we want documentclass[a4paper,12pt]{article} A We are telling LTEX we will do some “special tricks” usepackage[english,catalan]{babel} usepackage[ansinew]{inputenc} usepackage{geometry} usepackage{enumerate} We are signing our document title {The Denisova hominin} author {N.E.Ander et al.} date {Just about today} We are changing the default layout of the document parskip=5mm geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 7 / 41
  16. 16. A preamble: preamblesWhat is going on here? We are declaring the kind of document we want documentclass[a4paper,12pt]{article} A We are telling LTEX we will do some “special tricks” usepackage[english,catalan]{babel} usepackage[ansinew]{inputenc} usepackage{geometry} usepackage{enumerate} We are signing our document title {The Denisova hominin} author {N.E.Ander et al.} date {Just about today} We are changing the default layout of the document parskip=5mm geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 7 / 41
  17. 17. A preamble: preamblesWhat is going on here? We are declaring the kind of document we want documentclass[a4paper,12pt]{article} A We are telling LTEX we will do some “special tricks” usepackage[english,catalan]{babel} usepackage[ansinew]{inputenc} usepackage{geometry} usepackage{enumerate} We are signing our document title {The Denisova hominin} author {N.E.Ander et al.} date {Just about today} We are changing the default layout of the document parskip=5mm geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 7 / 41
  18. 18. A preamble: preamblesWhat is going on here? We are declaring the kind of document we want documentclass[a4paper,12pt]{article} A We are telling LTEX we will do some “special tricks” usepackage[english,catalan]{babel} usepackage[ansinew]{inputenc} usepackage{geometry} usepackage{enumerate} We are signing our document title {The Denisova hominin} author {N.E.Ander et al.} date {Just about today} We are changing the default layout of the document parskip=5mm geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 7 / 41
  19. 19. A preamble: preamblesWhat is going on here? We are declaring the kind of document we want documentclass[a4paper,12pt]{article} A We are telling LTEX we will do some “special tricks” usepackage[english,catalan]{babel} usepackage[ansinew]{inputenc} usepackage{geometry} usepackage{enumerate} We are signing our document title {The Denisova hominin} author {N.E.Ander et al.} date {Just about today} We are changing the default layout of the document parskip=5mm geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 7 / 41
  20. 20. A preamble: preamblesRemember! Title, author and date do not appear by default maketitle Something similar happens with languages selectlanguage{catalan} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 8 / 41
  21. 21. A preamble: preamblesRemember! Title, author and date do not appear by default maketitle Something similar happens with languages selectlanguage{catalan} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 8 / 41
  22. 22. A preamble: preamblesRemember! Title, author and date do not appear by default maketitle Something similar happens with languages selectlanguage{catalan} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 8 / 41
  23. 23. A preamble: preamblesRemember! Title, author and date do not appear by default maketitle Something similar happens with languages selectlanguage{catalan} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 8 / 41
  24. 24. A preamble: preambles Styling with styleJust a word on styling: Font Size this text is tiny this text is in scriptsize this text is in footnotesize this text is still small this is the normalsize this text is large this text is Large Man, this text is LARGE this is huge this is really Huge Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 9 / 41
  25. 25. A preamble: preambles Styling with styleJust a word on styling: Text Alignment AText in LTEX can be aligned as you like, you just have to say how that is. You rather have it centered, to the left or to the right?begin{flushleft} Text in LaTeX can be aligned as you like,end{flushleft}begin{center} you just have to say how that is. You rather have itend{center}begin{flushright} centered, to the left or to the right?end{flushright} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 10 / 41
  26. 26. A preamble: preambles Styling with styleJust a word on styling: Text Alignment AText in LTEX can be aligned as you like, you just have to say how that is. You rather have it centered, to the left or to the right?begin{flushleft} Text in LaTeX can be aligned as you like,end{flushleft}begin{center} you just have to say how that is. You rather have itend{center}begin{flushright} centered, to the left or to the right?end{flushright} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 10 / 41
  27. 27. Listing the listsOutline1 A preamble: preambles Styling with style2 Listing the lists Itemizing stuff Enumerating stuff Defining stuff3 Floating elements Imagine images Why must there always be a table? Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 11 / 41
  28. 28. Listing the listsThree examples of lists Itemizing only puts bullets. . . . . . it makes an unordered list. 1 Enumeration numbers each item. . . 2 . . . automatically, of course. Description is seldom used, though it’s nice. Items are put as in a dictionary. Borrega & Martins (UB) Introduction to L TEX Session #2 A January 21, 2013 12 / 41
  29. 29. Listing the listsThree examples of lists Itemizing only puts bullets. . . . . . it makes an unordered list. 1 Enumeration numbers each item. . . 2 . . . automatically, of course. Description is seldom used, though it’s nice. Items are put as in a dictionary. Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 12 / 41
  30. 30. Listing the listsThree examples of lists Itemizing only puts bullets. . . . . . it makes an unordered list. 1 Enumeration numbers each item. . . 2 . . . automatically, of course. Description is seldom used, though it’s nice. Items are put as in a dictionary. Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 12 / 41
  31. 31. Listing the listsThree examples of lists Itemizing only puts bullets. . . . . . it makes an unordered list. 1 Enumeration numbers each item. . . 2 . . . automatically, of course. Description is seldom used, though it’s nice. Items are put as in a dictionary. Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 12 / 41
  32. 32. Listing the lists Itemizing stuffItemizing stuff The basic way:begin{itemize} item First item item Second item item Third itemend{itemize} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 13 / 41
  33. 33. Listing the lists Itemizing stuffItemizing stuff Itemization provides four levels, by nesting several itemize environmentsbegin{itemize} item First level begin{itemize} item Second level begin{itemize} item Third level begin{itemize} item Fourth level end{itemize} end{itemize} end{itemize}end{itemize} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 14 / 41
  34. 34. Listing the lists Itemizing stuffItemizing stuff Itemization provides four levels, by nesting several itemize environmentsbegin{itemize} item First level begin{itemize} item Second level begin{itemize} item Third level begin{itemize} item Fourth level end{itemize} end{itemize} end{itemize}end{itemize} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 14 / 41
  35. 35. Listing the lists Itemizing stuffA quick challenge First level Second level First level Second level Third level Second level Third level Third level First level Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 15 / 41
  36. 36. Listing the lists Itemizing stuffWas it hard?begin{itemize} item First level begin{itemize} item Second level end{itemize} item First level begin{itemize} item Second level begin{itemize} item Third level end{itemize} item Second level begin{itemize} item Third level item Third level end{itemize} end{itemize} item First levelend{itemize} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 16 / 41
  37. 37. Listing the lists Enumerating stuffEnumerating stuff The basic way, almost like itemizing:begin{enumerate} item First item item Second item item Third itemend{enumerate} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 17 / 41
  38. 38. Listing the lists Enumerating stuffEnumerating stuff Like with itemization, four levels are provided with different numeration symbols: Arabic numbers, bracketted latin letters, roman numbers and capital latin letters. Good news is: it is very easy to change those symbols: (i) roman numbers (ii) with brackets 1) arabic numbers 2) with a single bracket A.- capital latin letters B.- with a dot and a dash∀(x) →1 meaningless logical formula∀(x) →2 and an arabic number Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 18 / 41
  39. 39. Listing the lists Enumerating stuffEnumerating stuff Like with itemization, four levels are provided with different numeration symbols: Arabic numbers, bracketted latin letters, roman numbers and capital latin letters. Good news is: it is very easy to change those symbols: (i) roman numbers (ii) with brackets 1) arabic numbers 2) with a single bracket A.- capital latin letters B.- with a dot and a dash∀(x) →1 meaningless logical formula∀(x) →2 and an arabic number Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 18 / 41
  40. 40. Listing the lists Enumerating stuffEnumerating stuff Like with itemization, four levels are provided with different numeration symbols: Arabic numbers, bracketted latin letters, roman numbers and capital latin letters. Good news is: it is very easy to change those symbols: (i) roman numbers (ii) with brackets 1) arabic numbers 2) with a single bracket A.- capital latin letters B.- with a dot and a dash∀(x) →1 meaningless logical formula∀(x) →2 and an arabic number Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 18 / 41
  41. 41. Listing the lists Enumerating stuff. . . enumeration not enumerating any more! You can even make enumeration look like an itemized list: - with dashes - and nothing else % with percent symbols % if you fancy with nothing at all (really, this is an enumeration too) :-) with anything :-) that you want ;-) Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 19 / 41
  42. 42. Listing the lists Enumerating stuff. . . enumeration not enumerating any more! You can even make enumeration look like an itemized list: - with dashes - and nothing else % with percent symbols % if you fancy with nothing at all (really, this is an enumeration too) :-) with anything :-) that you want ;-) Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 19 / 41
  43. 43. Listing the lists Enumerating stuff. . . enumeration not enumerating any more! You can even make enumeration look like an itemized list: - with dashes - and nothing else % with percent symbols % if you fancy with nothing at all (really, this is an enumeration too) :-) with anything :-) that you want ;-) Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 19 / 41
  44. 44. Listing the lists Enumerating stuff. . . enumeration not enumerating any more! You can even make enumeration look like an itemized list: - with dashes - and nothing else % with percent symbols % if you fancy with nothing at all (really, this is an enumeration too) :-) with anything :-) that you want ;-) Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 19 / 41
  45. 45. Listing the lists Enumerating stuff. . . enumeration not enumerating any more! You can even make enumeration look like an itemized list: - with dashes - and nothing else % with percent symbols % if you fancy with nothing at all (really, this is an enumeration too) :-) with anything :-) that you want ;-) Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 19 / 41
  46. 46. Listing the lists Enumerating stuffSome examplesusepackage{enumerate}begin{enumerate}[(i)] item roman numbers item with bracketsend{enumerate}begin{enumerate}[] item with nothing at all item (really, this is an enumeration too)end{enumerate}begin{enumerate}[:-)] item with anything item that you want ;-)end{enumerate} Borrega & Martins (UB) Introduction to L TEX Session #2 A January 21, 2013 20 / 41
  47. 47. Listing the lists Defining stuffDefining stuff The basic way. Notice the defined term is entered as an optional argument to item:begin{description} item[One] First item item[Two] Second item item[Three] Third itemend{description} Borrega & Martins (UB) Introduction to L TEX Session #2 A January 21, 2013 21 / 41
  48. 48. Listing the lists Defining stuffDefining stuff It looks good, as in a dictionary: One First item Two Second item Three Third item Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 22 / 41
  49. 49. Floating elementsOutline1 A preamble: preambles Styling with style2 Listing the lists Itemizing stuff Enumerating stuff Defining stuff3 Floating elements Imagine images Why must there always be a table? Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 23 / 41
  50. 50. Floating elementsWhy “floating”? There are two basic types: figures and tables A They do not have a fixed placing in the page: LTEX decides where is best to anchor them so they don’t interrupt the flow of the text They are containers to elements that cannot be split or broken between pages. Additionally, they have a caption defining them, and they are numbered (so they can be referred to easily in the text). Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 24 / 41
  51. 51. Floating elementsWhy “floating”? There are two basic types: figures and tables A They do not have a fixed placing in the page: LTEX decides where is best to anchor them so they don’t interrupt the flow of the text They are containers to elements that cannot be split or broken between pages. Additionally, they have a caption defining them, and they are numbered (so they can be referred to easily in the text). Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 24 / 41
  52. 52. Floating elementsWhy “floating”? There are two basic types: figures and tables A They do not have a fixed placing in the page: LTEX decides where is best to anchor them so they don’t interrupt the flow of the text They are containers to elements that cannot be split or broken between pages. Additionally, they have a caption defining them, and they are numbered (so they can be referred to easily in the text). Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 24 / 41
  53. 53. Floating elementsWhy “floating”? There are two basic types: figures and tables A They do not have a fixed placing in the page: LTEX decides where is best to anchor them so they don’t interrupt the flow of the text They are containers to elements that cannot be split or broken between pages. Additionally, they have a caption defining them, and they are numbered (so they can be referred to easily in the text). Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 24 / 41
  54. 54. Floating elements Imagine imagesFigures: an example Figure: Not this kind of latex Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 25 / 41
  55. 55. Floating elements Imagine imagesHands on: lets include an image First of all, we must declare the graphicx packageusepackage{graphicx} Then, we prepare the figure environmentbegin{figure}[h] ldotsend{figure} Notice the [h] there? Borrega & Martins (UB) Introduction to L TEX Session #2 A January 21, 2013 26 / 41
  56. 56. Floating elements Imagine imagesHands on: lets include an image First of all, we must declare the graphicx packageusepackage{graphicx} Then, we prepare the figure environmentbegin{figure}[h] ldotsend{figure} Notice the [h] there? Borrega & Martins (UB) Introduction to L TEX Session #2 A January 21, 2013 26 / 41
  57. 57. Floating elements Imagine imagesHands on: lets include an image First of all, we must declare the graphicx packageusepackage{graphicx} Then, we prepare the figure environmentbegin{figure}[h] ldotsend{figure} Notice the [h] there? Borrega & Martins (UB) Introduction to L TEX Session #2 A January 21, 2013 26 / 41
  58. 58. Floating elements Imagine imagesHands off! Placing floatsAll floats take an optional argument: the place specifier.There are four possible values: h → here t → top b → bottom p → sepparate page just for floatsThey can be forced by adding an exclamation mark ([h!]) AHowever, in the end, they are just a suggestion: LTEX has the final word Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 27 / 41
  59. 59. Floating elements Imagine imagesHands off! Placing floatsAll floats take an optional argument: the place specifier.There are four possible values: h → here t → top b → bottom p → sepparate page just for floatsThey can be forced by adding an exclamation mark ([h!]) AHowever, in the end, they are just a suggestion: LTEX has the final word Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 27 / 41
  60. 60. Floating elements Imagine imagesHands off! Placing floatsAll floats take an optional argument: the place specifier.There are four possible values: h → here t → top b → bottom p → sepparate page just for floatsThey can be forced by adding an exclamation mark ([h!]) AHowever, in the end, they are just a suggestion: LTEX has the final word Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 27 / 41
  61. 61. Floating elements Imagine imagesHands on (again): lets include an image A Next step: tell LTEX what image we want to include, and how big it must bebegin{figure}[h] includegraphics[width=5cm]{images/image.png}end{figure} Regarding size, we can tinker with Image width → [width=Xcm] Image height → [height=Xcm] Scaling factor → [scale=1.5] Rotation angle (in degrees) → [angle=X] Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 28 / 41
  62. 62. Floating elements Imagine imagesHands on (again): lets include an image A Next step: tell LTEX what image we want to include, and how big it must bebegin{figure}[h] includegraphics[width=5cm]{images/image.png}end{figure} Regarding size, we can tinker with Image width → [width=Xcm] Image height → [height=Xcm] Scaling factor → [scale=1.5] Rotation angle (in degrees) → [angle=X] Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 28 / 41
  63. 63. Floating elements Imagine imagesHands on (again): lets include an image A Next step: tell LTEX what image we want to include, and how big it must bebegin{figure}[h] includegraphics[width=5cm]{images/image.png}end{figure} Regarding size, we can tinker with Image width → [width=Xcm] Image height → [height=Xcm] Scaling factor → [scale=1.5] Rotation angle (in degrees) → [angle=X] Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 28 / 41
  64. 64. Floating elements Imagine imagesHands on (again): lets include an image A Next step: tell LTEX what image we want to include, and how big it must bebegin{figure}[h] includegraphics[width=5cm]{images/image.png}end{figure} Regarding size, we can tinker with Image width → [width=Xcm] Image height → [height=Xcm] Scaling factor → [scale=1.5] Rotation angle (in degrees) → [angle=X] Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 28 / 41
  65. 65. Floating elements Imagine imagesHands on (again): lets include an image A Next step: tell LTEX what image we want to include, and how big it must bebegin{figure}[h] includegraphics[width=5cm]{images/image.png}end{figure} Regarding size, we can tinker with Image width → [width=Xcm] Image height → [height=Xcm] Scaling factor → [scale=1.5] Rotation angle (in degrees) → [angle=X] Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 28 / 41
  66. 66. Floating elements Imagine imagesHands on (again): lets include an image Finally, we can add a caption to the image (either before or after the image itself, within the environment)begin{figure}[h] includegraphics[width=5cm]{images/image.png} caption{This image has served us as a tutorial.}end{figure} Borrega & Martins (UB) Introduction to L TEX Session #2 A January 21, 2013 29 / 41
  67. 67. Floating elements Imagine imagesImagine not only imagesAlthough this is not as common, the contents of the figure environmentcan be text. For instance:Com evident experi`ncia mostra, la debilitat de la nostra mem`ria, sotsmetent f`cilment e o a a oblivi´ no solament los actes per longitud de temps envellits, mas encara los actes ofrescs de nostres dies, ´s estat doncs molt condecent, util e expedient deduir en escrit les e ´ gestes e hist`ries antigues dels homens forts e virtuosos, com sien espills molt clars, o exemples e virtuosa doctrina de nostra vida, segons recita aquell gran orador Tul·li. Figura: A fragment of Tirant lo Blanc Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 30 / 41
  68. 68. Floating elements Imagine imagesImagine not only imagesAlthough this is not as common, the contents of the figure environmentcan be text. For instance:Com evident experi`ncia mostra, la debilitat de la nostra mem`ria, sotsmetent f`cilment e o a a oblivi´ no solament los actes per longitud de temps envellits, mas encara los actes ofrescs de nostres dies, ´s estat doncs molt condecent, util e expedient deduir en escrit les e ´ gestes e hist`ries antigues dels homens forts e virtuosos, com sien espills molt clars, o exemples e virtuosa doctrina de nostra vida, segons recita aquell gran orador Tul·li. Figura: A fragment of Tirant lo Blanc Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 30 / 41
  69. 69. Floating elements Why must there always be a table?Ready? The tough part begins now... ...so take a deep breath.The fun part begins now! Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 31 / 41
  70. 70. Floating elements Why must there always be a table?How a table looks like in the final .pdf... JOHN MARY JAMES Monday ironing cooking vacuum cleaning Tuesday cooking dusting sweeping Wednesday shopping Thursday bathroom cleaning cooking Friday rest Table: This table is neat! Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 32 / 41
  71. 71. Floating elements Why must there always be a table?...and how it looks like in the .texbegin{table}[h!]begin{tabular}{|c|c|c|c|}cline{2-4}multicolumn{1}{c|}{} & JOHN & MARY & JAMES hlineMonday & ironing & cooking & vacuum cleaning hlineTuesday & cooking & dusting & sweeping cline{1-1}cline{3-4}Wednesday & & multicolumn{2}{c|}{shopping}hlineThursday & multicolumn{2}{c|}{bathroom cleaning} & cooking hlineFriday & multicolumn{3}{c|}{rest}hlineend{tabular}caption{This table is neat!}end{table} Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 33 / 41
  72. 72. Floating elements Why must there always be a table?Lets walk through it step by step First, we prepare the table environmentbegin{table}[ht!] ...caption{This table is neat!}end{table} caption is optional Borrega & Martins (UB) Introduction to L TEX Session #2 A January 21, 2013 34 / 41
  73. 73. Floating elements Why must there always be a table?Lets walk through it step by step First, we prepare the table environmentbegin{table}[ht!] ...caption{This table is neat!}end{table} caption is optional Borrega & Martins (UB) Introduction to L TEX Session #2 A January 21, 2013 34 / 41
  74. 74. Floating elements Why must there always be a table?Lets walk through it step by step Next, we create the table with the tabular environmentbegin{table}[ht!] begin{tabular}{alignment} ... end{tabular}caption{This table is neat!}end{table} Possible alignments are l (left), c (center) and r (right) Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 35 / 41
  75. 75. Floating elements Why must there always be a table?Lets walk through it step by step Next, we create the table with the tabular environmentbegin{table}[ht!] begin{tabular}{alignment} ... end{tabular}caption{This table is neat!}end{table} Possible alignments are l (left), c (center) and r (right) Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 35 / 41
  76. 76. Floating elements Why must there always be a table?Lets walk through it step by step Next, we create the table with the tabular environmentbegin{table}[ht!] begin{tabular}{rcl} ... end{tabular}caption{This table is neat!}end{table} Possible alignments are l (left), c (center) and r (right) Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 36 / 41
  77. 77. Floating elements Why must there always be a table?Lets walk through it step by step Finally, we add row after row of tablebegin{table}[ht!] begin{tabular}{rcl} A & B & C AA & BB & CC AAA & BBB & CCC AAAA & BBBB & CCCC end{tabular}caption{This table is neat!}end{table} The ampersand (&) is the column divider, a linebreak () finishes each row. Borrega & Martins (UB) Introduction to L TEX Session #2 A January 21, 2013 37 / 41
  78. 78. Floating elements Why must there always be a table?Ok, run it! if we run the previous code, we get... A B C AA BB CC AAA BBB CCC AAAA BBBB CCCC Table: This table is neat! Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 38 / 41
  79. 79. Floating elements Why must there always be a table?Ok, run it! if we run the previous code, we get... A B C AA BB CC AAA BBB CCC AAAA BBBB CCCC Table: This table is neat! Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 38 / 41
  80. 80. Floating elements Why must there always be a table?Lets add linesbegin{table}[ht!] begin{tabular}{|r|c|l|} hline A & B & C hline AA & BB & CC cline{1-2} AAA & BBB & CCC cline{2-3} AAAA & BBBB & CCCC hline end{tabular}caption{This table is neat!}end{table} Borrega & Martins (UB) Introduction to L TEX Session #2 A January 21, 2013 39 / 41
  81. 81. Floating elements Why must there always be a table?Lets add lines A B C AA BB CC AAA BBB CCC AAAA BBBB CCCC Table: This table is neat! Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 40 / 41
  82. 82. Floating elements Why must there always be a table?Another quick challenge COLUMN A COLUMN B COLUMN C ROW 1 A1 B1 C1 ROW 2 A2 B2 C2 ROW 3 A3 B3 C3 Table: This table is a quick exercise Borrega & Martins (UB) A Introduction to L TEX Session #2 January 21, 2013 41 / 41

×