overleaf/services/web/app/views/external/learn.jade
2014-06-20 17:17:24 +01:00

714 lines
33 KiB
Text

extends ../layout
block content
.container
.row
.offset2.span8
#bodyContent
h1 Positioning images and tables
#mw-content-text.mw-content-ltr(lang='en', dir='ltr')
p
span.texhtml(style='font-family: \'CMU Serif\', cmr10, LMRoman10-Regular, \'Times New Roman\', \'Nimbus Roman No9 L\', Times, serif;')
| L
span(style='text-transform: uppercase; font-size: 70%; margin-left: -0.36em; vertical-align: 0.3em; line-height: 0; margin-right: -0.15em;') a
| T
span(style='text-transform: uppercase; margin-left: -0.1667em; vertical-align: -0.5ex; line-height: 0; margin-right: -0.125em;') e
| X
| is an editing tool that takes care of the format so you only have to worry about the contents of your document. Nevertheless, sometimes a better control of floating elements is necessary. This article explains how to position images and tables in a
span.texhtml(style='font-family: \'CMU Serif\', cmr10, LMRoman10-Regular, \'Times New Roman\', \'Nimbus Roman No9 L\', Times, serif;')
| L
span(style='text-transform: uppercase; font-size: 70%; margin-left: -0.36em; vertical-align: 0.3em; line-height: 0; margin-right: -0.15em;') a
| T
span(style='text-transform: uppercase; margin-left: -0.1667em; vertical-align: -0.5ex; line-height: 0; margin-right: -0.125em;') e
| X
| document.
table#toc.toc
tbody
tr
td
#toctitle
h2 Contents
span.toctoggle
| [
a#togglelink.internal(href='#') hide
| ]
ul
li.toclevel-1.tocsection-1
a(href='#Introduction')
span.tocnumber 1
span.toctext Introduction
li.toclevel-1.tocsection-2
a(href='#Positioning_images')
span.tocnumber 2
span.toctext Positioning images
ul
li.toclevel-2.tocsection-3
a(href='#Basic_positioning')
span.tocnumber 2.1
span.toctext Basic positioning
li.toclevel-2.tocsection-4
a(href='#The_figure_environment')
span.tocnumber 2.2
span.toctext The figure environment
li.toclevel-2.tocsection-5
a(href='#Multiple_images_in_one_figure')
span.tocnumber 2.3
span.toctext Multiple images in one figure
li.toclevel-2.tocsection-6
a(href='#Wrapping_text_around_a_figure')
span.tocnumber 2.4
span.toctext Wrapping text around a figure
li.toclevel-1.tocsection-7
a(href='#Positioning_tables')
span.tocnumber 3
span.toctext Positioning tables
ul
li.toclevel-2.tocsection-8
a(href='#Basic_positioning_2')
span.tocnumber 3.1
span.toctext Basic positioning
li.toclevel-2.tocsection-9
a(href='#The_table_environment')
span.tocnumber 3.2
span.toctext The table environment
li.toclevel-2.tocsection-10
a(href='#Wrapping_text_around_a_table')
span.tocnumber 3.3
span.toctext Wrapping text around a table
li.toclevel-1.tocsection-11
a(href='#Reference_guide')
span.tocnumber 4
span.toctext Reference guide
li.toclevel-1.tocsection-12
a(href='#Further_reading')
span.tocnumber 5
span.toctext Further reading
h1
span#Introduction.mw-headline Introduction
p
| The default alignment for images and tables is set to
i left
figure.wikifigure
.row-fluid
.span6
pre(data-number)
| \nLorem ipsum dolor sit amet, consectetuer adipiscing elit.
| Etiam lobortis facilisis sem. Nullam nec mi et neque pharetra
| sollicitudin.
br
br
| Praesent imperdiet mi nec
| ante. Donec ullamcorper, felis non sodales commodo, lectus velit
| ultrices augue, a dignissim nibh lectus placerat pede.
| Vivamus nunc nunc, molestie ut, ultricies
| vel, semper in, velit. Ut porttitor.
.span6
a(href='/learn/File:PositioningTnIEX1.png')
img(alt='PositioningTnIEX1.png', src='/learn-scripts/images/thumb/2/23/PositioningTnIEX1.png/300px-PositioningTnIEX1.png', width='300', height='233')
figcaption
strong Figure 1.
| Positioning floats within a document.
p
p
| This is a simple example, for a description of this and other ways to include images in your
span.texhtml(style='font-family: \'CMU Serif\', cmr10, LMRoman10-Regular, \'Times New Roman\', \'Nimbus Roman No9 L\', Times, serif;')
| L
span(style='text-transform: uppercase; font-size: 70%; margin-left: -0.36em; vertical-align: 0.3em; line-height: 0; margin-right: -0.15em;') a
| T
span(style='text-transform: uppercase; margin-left: -0.1667em; vertical-align: -0.5ex; line-height: 0; margin-right: -0.125em;') e
| X
| file see the article
a(href='/learn/Inserting_Images', title='Inserting Images') Inserting Images
| .
p
a.external.text(rel='nofollow', href='https://www.sharelatex.com/project/new/template?zipUrl=/project/532cda2653f42c100f002b56/download/zip&templateName=PositioningTablesandFigures&compiler=pdflatex')
img(alt='Open.png', src='/learn-scripts/images/7/7f/Open.png', width='24', height='24', style='vertical-align: middle;')
| Open an example in ShareLaTeX
h1
span#Positioning_images.mw-headline Positioning images
h2
span#Basic_positioning.mw-headline Basic positioning
p
| To change the default alignment of a image from
i left
| or
i right
| an easy manner is to add
.mw-geshi.mw-code.mw-content-ltr(dir='ltr')
.latex.source-latex
pre.de1.
p
| to the preamble of your file and then use an additional option in your image importing statement
p
figure.wikifigure
.row-fluid
.span6
pre(data-number)
| \nLorem ipsum dolor sit amet, consectetuer adipiscing elit.
| Etiam lobortis facilisis sem. Nullam nec mi et neque pharetra
| sollicitudin.
br
br
| Praesent imperdiet mi nec
| ante. Donec ullamcorper, felis non sodales commodo, lectus velit
| ultrices augue, a dignissim nibh lectus placerat pede.
| Vivamus nunc nunc, molestie ut, ultricies
| vel, semper in, velit. Ut porttitor.
.span6
a(href='/learn/File:PositioningTnIEX1.png')
img(alt='PositioningTnIEX1.png', src='/learn-scripts/images/thumb/2/23/PositioningTnIEX1.png/300px-PositioningTnIEX1.png', width='300', height='233')
figcaption
strong Figure 1.
| Positioning floats within a document.
p
| The package
b adjustbox
| enables an additional option in the
code \includegraphics
| command, in the example the picture is aligned to
code right
| . The available values are:
i left
| ,
i right
| ,
i center
| ,
i outer
| and
i inner
| , the last two are intended for two-sided documents.
p
a.external.text(rel='nofollow', href='https://www.sharelatex.com/project/new/template?zipUrl=/project/532cda2653f42c100f002b56/download/zip&templateName=PositioningTablesandFigures&compiler=pdflatex')
img(alt='Open.png', src='/learn-scripts/images/7/7f/Open.png', width='24', height='24', style='vertical-align: middle;')
| Open an example in ShareLaTeX
h2
span#The_figure_environment.mw-headline The figure environment
p
| The figure environment (see
a(href='/learn/Inserting_Images', title='Inserting Images') Inserting Images
| ) is intended to provide automatic positioning.
p
figure.wikifigure
.row-fluid
.span6
pre(data-number)
| \nLorem ipsum dolor sit amet, consectetuer adipiscing elit.
| Etiam lobortis facilisis sem. Nullam nec mi et neque pharetra
| sollicitudin.
br
br
| Praesent imperdiet mi nec
| ante. Donec ullamcorper, felis non sodales commodo, lectus velit
| ultrices augue, a dignissim nibh lectus placerat pede.
| Vivamus nunc nunc, molestie ut, ultricies
| vel, semper in, velit. Ut porttitor.
.span6
a(href='/learn/File:PositioningTnIEX1.png')
img(alt='PositioningTnIEX1.png', src='/learn-scripts/images/thumb/2/23/PositioningTnIEX1.png/300px-PositioningTnIEX1.png', width='300', height='233')
figcaption
strong Figure 1.
| Positioning floats within a document.
p
| This environment uses a positioning parameter passed inside brackets, it can take the next values:
table.wikitable
tbody
tr
th
| Parameter
th
| Position
tr
td
tt h
td
| Place the float
i here
| , i.e.,
i approximately
| at the same point it occurs in the source text (however, not
i exactly
| at the spot)
tr
td
tt t
td
| Position at the
i top
| of the page.
tr
td
tt b
td
| Position at the
i bottom
| of the page.
tr
td
tt p
td
| Put on a special
i page
| for floats only.
tr
td
tt !
td
| Override internal parameters LaTeX uses for determining "good" float positions.
tr
td
tt H
td
| Places the float at precisely the location in the
span.texhtml(style='font-family: \'CMU Serif\', cmr10, LMRoman10-Regular, \'Times New Roman\', \'Nimbus Roman No9 L\', Times, serif;')
| L
span(style='text-transform: uppercase; font-size: 70%; margin-left: -0.36em; vertical-align: 0.3em; line-height: 0; margin-right: -0.15em;') a
| T
span(style='text-transform: uppercase; margin-left: -0.1667em; vertical-align: -0.5ex; line-height: 0; margin-right: -0.125em;') e
| X
| code. Requires the
code float
| package. This is somewhat equivalent to
tt h!
| .
p
| You can put more than one value in the parameter, for instance, if you write
code [ht]
span.texhtml(style='font-family: \'CMU Serif\', cmr10, LMRoman10-Regular, \'Times New Roman\', \'Nimbus Roman No9 L\', Times, serif;')
| L
span(style='text-transform: uppercase; font-size: 70%; margin-left: -0.36em; vertical-align: 0.3em; line-height: 0; margin-right: -0.15em;') a
| T
span(style='text-transform: uppercase; margin-left: -0.1667em; vertical-align: -0.5ex; line-height: 0; margin-right: -0.125em;') e
| X
| will try to position the figure
b here
| , but if it's not possible (the space may be insufficient) then the figure will appear at the
b top
| of the page. It is recommended to use more than one positioning parameter to prevent unexpected results.
p
a.external.text(rel='nofollow', href='https://www.sharelatex.com/project/new/template?zipUrl=/project/532cda2653f42c100f002b56/download/zip&templateName=PositioningTablesandFigures&compiler=pdflatex')
img(alt='Open.png', src='/learn-scripts/images/7/7f/Open.png', width='24', height='24', style='vertical-align: middle;')
| Open an example in ShareLaTeX
h2
span#Multiple_images_in_one_figure.mw-headline Multiple images in one figure
p
| It is possible to insert several images in one figure, each one with its own reference and label
p
figure.wikifigure
.row-fluid
.span6
pre(data-number)
| \nLorem ipsum dolor sit amet, consectetuer adipiscing elit.
| Etiam lobortis facilisis sem. Nullam nec mi et neque pharetra
| sollicitudin.
br
br
| Praesent imperdiet mi nec
| ante. Donec ullamcorper, felis non sodales commodo, lectus velit
| ultrices augue, a dignissim nibh lectus placerat pede.
| Vivamus nunc nunc, molestie ut, ultricies
| vel, semper in, velit. Ut porttitor.
.span6
a(href='/learn/File:PositioningTnIEX1.png')
img(alt='PositioningTnIEX1.png', src='/learn-scripts/images/thumb/2/23/PositioningTnIEX1.png/300px-PositioningTnIEX1.png', width='300', height='233')
figcaption
strong Figure 1.
| Positioning floats within a document.
p
| First, you must import the package
b subcaption
| by adding to the preamble
.mw-geshi.mw-code.mw-content-ltr(dir='ltr')
.latex.source-latex
pre.de1.
p
| then you can use the environment
code \subfigure
| that takes one parameter, the width of the figure. This environment must be used inside a
code figure
| environment, captions and labels can be set to each
i subfigure
| .
p
a.external.text(rel='nofollow', href='https://www.sharelatex.com/project/new/template?zipUrl=/project/532cda2653f42c100f002b56/download/zip&templateName=PositioningTablesandFigures&compiler=pdflatex')
img(alt='Open.png', src='/learn-scripts/images/7/7f/Open.png', width='24', height='24', style='vertical-align: middle;')
| Open an example in ShareLaTeX
h2
span#Wrapping_text_around_a_figure.mw-headline Wrapping text around a figure
p
| The package
b wrapfig
| provides a useful feature, text can be floated around the images.
p
figure.wikifigure
.row-fluid
.span6
pre(data-number)
| \nLorem ipsum dolor sit amet, consectetuer adipiscing elit.
| Etiam lobortis facilisis sem. Nullam nec mi et neque pharetra
| sollicitudin.
br
br
| Praesent imperdiet mi nec
| ante. Donec ullamcorper, felis non sodales commodo, lectus velit
| ultrices augue, a dignissim nibh lectus placerat pede.
| Vivamus nunc nunc, molestie ut, ultricies
| vel, semper in, velit. Ut porttitor.
.span6
a(href='/learn/File:PositioningTnIEX1.png')
img(alt='PositioningTnIEX1.png', src='/learn-scripts/images/thumb/2/23/PositioningTnIEX1.png/300px-PositioningTnIEX1.png', width='300', height='233')
figcaption
strong Figure 1.
| Positioning floats within a document.
p
| First import the package
i wrapfig
| by adding
.mw-geshi.mw-code.mw-content-ltr(dir='ltr')
.latex.source-latex
pre.de1.
p
| to the preamble.
p
| After that you can use the environment
code wrapfig
| , it takes two parameters that are passed inside braces: the alignement that can be
i l
| ,
i r
| ,
i c
| ,
i i
| or
i o
| ; this letters stand for left, right, centre, inner and outer (the last two intended for two-sided documents). The second parameter is the width of the figure, in the example is 0.25 the width of the text. See the
a(href='#Reference_guide') reference guide
| for a list of possible length units.
p
a.external.text(rel='nofollow', href='https://www.sharelatex.com/project/new/template?zipUrl=/project/532cda2653f42c100f002b56/download/zip&templateName=PositioningTablesandFigures&compiler=pdflatex')
img(alt='Open.png', src='/learn-scripts/images/7/7f/Open.png', width='24', height='24', style='vertical-align: middle;')
| Open an example in ShareLaTeX
h1
span#Positioning_tables.mw-headline Positioning tables
p
| Options for table positioning are similar to those available for figures
h2
span#Basic_positioning_2.mw-headline Basic positioning
p
| Default position of the tabular environment is
i centre
| .
p
figure.wikifigure
.row-fluid
.span6
pre(data-number)
| \nLorem ipsum dolor sit amet, consectetuer adipiscing elit.
| Etiam lobortis facilisis sem. Nullam nec mi et neque pharetra
| sollicitudin.
br
br
| Praesent imperdiet mi nec
| ante. Donec ullamcorper, felis non sodales commodo, lectus velit
| ultrices augue, a dignissim nibh lectus placerat pede.
| Vivamus nunc nunc, molestie ut, ultricies
| vel, semper in, velit. Ut porttitor.
.span6
a(href='/learn/File:PositioningTnIEX1.png')
img(alt='PositioningTnIEX1.png', src='/learn-scripts/images/thumb/2/23/PositioningTnIEX1.png/300px-PositioningTnIEX1.png', width='300', height='233')
figcaption
strong Figure 1.
| Positioning floats within a document.
p
| To learn about how to create tables see the
a(href='/learn/Tables', title='Tables') Tables
| article.
p
a.external.text(rel='nofollow', href='https://www.sharelatex.com/project/new/template?zipUrl=/project/532cda2653f42c100f002b56/download/zip&templateName=PositioningTablesandFigures&compiler=pdflatex')
img(alt='Open.png', src='/learn-scripts/images/7/7f/Open.png', width='24', height='24', style='vertical-align: middle;')
| Open an example in ShareLaTeX
h2
span#The_table_environment.mw-headline The table environment
p
| The table environment is intended to automatically position tables so they fit nicely in the flow of your document.
p
figure.wikifigure
.row-fluid
.span6
pre(data-number)
| \nLorem ipsum dolor sit amet, consectetuer adipiscing elit.
| Etiam lobortis facilisis sem. Nullam nec mi et neque pharetra
| sollicitudin.
br
br
| Praesent imperdiet mi nec
| ante. Donec ullamcorper, felis non sodales commodo, lectus velit
| ultrices augue, a dignissim nibh lectus placerat pede.
| Vivamus nunc nunc, molestie ut, ultricies
| vel, semper in, velit. Ut porttitor.
.span6
a(href='/learn/File:PositioningTnIEX1.png')
img(alt='PositioningTnIEX1.png', src='/learn-scripts/images/thumb/2/23/PositioningTnIEX1.png/300px-PositioningTnIEX1.png', width='300', height='233')
figcaption
strong Figure 1.
| Positioning floats within a document.
p
| A position parameter, inside brackets, can be passed to the
b table
| environment. This parameter can take the next values:
table.wikitable
tbody
tr
th
| Parameter
th
| Position
tr
td
tt h
td
| Place the float
i here
| , i.e.,
i approximately
| at the same point it occurs in the source text (however, not
i exactly
| at the spot)
tr
td
tt t
td
| Position at the
i top
| of the page.
tr
td
tt b
td
| Position at the
i bottom
| of the page.
tr
td
tt p
td
| Put on a special
i page
| for floats only.
tr
td
tt !
td
| Override internal parameters LaTeX uses for determining "good" float positions.
tr
td
tt H
td
| Places the float at precisely the location in the
span.texhtml(style='font-family: \'CMU Serif\', cmr10, LMRoman10-Regular, \'Times New Roman\', \'Nimbus Roman No9 L\', Times, serif;')
| L
span(style='text-transform: uppercase; font-size: 70%; margin-left: -0.36em; vertical-align: 0.3em; line-height: 0; margin-right: -0.15em;') a
| T
span(style='text-transform: uppercase; margin-left: -0.1667em; vertical-align: -0.5ex; line-height: 0; margin-right: -0.125em;') e
| X
| code. Requires the
code float
| package. This is somewhat equivalent to
tt h!
| .
p
| You can set more than one value in the parameter, for instance, if you write
code [ht]
span.texhtml(style='font-family: \'CMU Serif\', cmr10, LMRoman10-Regular, \'Times New Roman\', \'Nimbus Roman No9 L\', Times, serif;')
| L
span(style='text-transform: uppercase; font-size: 70%; margin-left: -0.36em; vertical-align: 0.3em; line-height: 0; margin-right: -0.15em;') a
| T
span(style='text-transform: uppercase; margin-left: -0.1667em; vertical-align: -0.5ex; line-height: 0; margin-right: -0.125em;') e
| X
| will try to position the table
b here
| , but if it's not possible (the space may be insufficient) then the table will appear at the
b top
| of the page. It is recommended to use more than one positioning parameter to prevent unexpected results.
p
| Notice also the command
code \centering
| . This changes the alignment of the table within its container to
i centre
| instead of the default
i left
| .
p
a.external.text(rel='nofollow', href='https://www.sharelatex.com/project/new/template?zipUrl=/project/532cda2653f42c100f002b56/download/zip&templateName=PositioningTablesandFigures&compiler=pdflatex')
img(alt='Open.png', src='/learn-scripts/images/7/7f/Open.png', width='24', height='24', style='vertical-align: middle;')
| Open an example in ShareLaTeX
h2
span#Wrapping_text_around_a_table.mw-headline Wrapping text around a table
p
| If your table don't take all available space and you want to put text next or before it, is possible with the package
b wraptable
| .
p
figure.wikifigure
.row-fluid
.span6
pre(data-number)
| \nLorem ipsum dolor sit amet, consectetuer adipiscing elit.
| Etiam lobortis facilisis sem. Nullam nec mi et neque pharetra
| sollicitudin.
br
br
| Praesent imperdiet mi nec
| ante. Donec ullamcorper, felis non sodales commodo, lectus velit
| ultrices augue, a dignissim nibh lectus placerat pede.
| Vivamus nunc nunc, molestie ut, ultricies
| vel, semper in, velit. Ut porttitor.
.span6
a(href='/learn/File:PositioningTnIEX1.png')
img(alt='PositioningTnIEX1.png', src='/learn-scripts/images/thumb/2/23/PositioningTnIEX1.png/300px-PositioningTnIEX1.png', width='300', height='233')
figcaption
strong Figure 1.
| Positioning floats within a document.
p
| First, import the package
.mw-geshi.mw-code.mw-content-ltr(dir='ltr')
.latex.source-latex
pre.de1.
p
| then you can use the environment
i wraptable
| which takes two parameters: The first one is the alignment that can be
i l
| ,
i r
| ,
i c
| ,
i i
| or
i o
| for left, right, centre, inner and outer respectively. The second one is the width of the table container, keep in mind that this latter parameter must be the same as the width of the table, otherwise things may not be properly aligned.
p
a.external.text(rel='nofollow', href='https://www.sharelatex.com/project/new/template?zipUrl=/project/532cda2653f42c100f002b56/download/zip&templateName=PositioningTablesandFigures&compiler=pdflatex')
img(alt='Open.png', src='/learn-scripts/images/7/7f/Open.png', width='24', height='24', style='vertical-align: middle;')
| Open an example in ShareLaTeX
h1
span#Reference_guide.mw-headline Reference guide
p
b
span.texhtml(style='font-family: \'CMU Serif\', cmr10, LMRoman10-Regular, \'Times New Roman\', \'Nimbus Roman No9 L\', Times, serif;')
| L
span(style='text-transform: uppercase; font-size: 70%; margin-left: -0.36em; vertical-align: 0.3em; line-height: 0; margin-right: -0.15em;') a
| T
span(style='text-transform: uppercase; margin-left: -0.1667em; vertical-align: -0.5ex; line-height: 0; margin-right: -0.125em;') e
| X
| units and lengths
table.wikitable
tbody
tr
th
| Abbreviation
th
| Definition
tr
td
tt pt
td
| A point, is the default length unit. About 0.3515mm
tr
td
tt mm
td
| a millimetre
tr
td
tt cm
td
| a centimetre
tr
td
tt in
td
| an inch
tr
td
tt ex
td
| the height of an
b x
| in the current font
tr
td
tt em
td
| the width of an
b m
| in the current font
tr
td
tt \columnsep
td
| distance between columns
tr
td
tt \columnwidth
td
| width of the column
tr
td
tt \linewidth
td
| width of the line in the current environment
tr
td
tt \paperwidth
td
| width of the page
tr
td
tt \paperheight
td
| height of the page
tr
td
tt \textwidth
td
| width of the text
tr
td
tt \textheight
td
| height of the text
tr
td
tt \unitleght
td
| units of length in the
i picture
| environment.
h1
span#Further_reading.mw-headline Further reading
p
| For more information see the full package documentation
p
a.external.text(rel='nofollow', href='http://tug.ctan.org/tex-archive/macros/latex/contrib/floatrow/floatrow.pdf')
b floatrow
| package for advanced caption managing of floating elements (tables and figures)
p
a.external.text(rel='nofollow', href='ftp://ctan.tug.org/tex-archive/macros/latex/contrib/sidecap/sidecap.pdf')
b sidecap
| package documentation, for side-figure captions
.printfooter
| Retrieved from "
a(href='http://www.sharelatex.com/learn-scripts/index.php?title=Positioning_images_and_tables&oldid=2521')
| http://www.sharelatex.com/learn-scripts/index.php?title=Positioning_images_and_tables&oldid=2521
| "
include ../general/small-footer