Changes

Jump to navigation Jump to search
5,197 bytes added ,  15:13, 28 November 2021
m
Remove TEXpage from code snippets
< [[Visuals]] | [[Graphics]] | [[Using Graphics]] >= Introduction =
Floats are elements like tables or figures that Floating Objects (floats) are placed (and numbered) automatically by TeX, with a configurable (and optional) caption. They are so called as they can ''placed at an appropriate position determined by the TeX float'' around the output pages to placement algorithm. The algorithm has a place where TeX thinks they are appropriate (You number of options that can influence what TeX thinks as appropriate)float placement.
Floats Most options in the manual (such as {{cmd|placeexternalfigure}}) are ConTeXt's "base class" for everything that uses a <tt>\placedescribed using the generic {{cmd|placefloat}}...</tt> command (tableAdditionally, figure, own floats){{cmd|placelistoffigures}} creates a list of the figures used in the document.
If you search options of e.g. <cmd>placeexternalfigure</cmd> you must look after <cmd>placefloat</cmd> in the manual! (same for <tt>\setup...</tt> etc.) The float types Floats include "graphic", "figure", "table" , and "intermezzo" are readily defined. If you need more (i.e. if you need another numbering or table of something), you Additional floats can easily define your own floats with <be defined using {{cmd>|definefloat</cmd>}}.
<texcode>
<tr><td>page</td><td>on a new (empty) page</td></tr>
<tr bgcolor="#DDDDDD"><td>opposite</td><td>on the left page</td></tr>
<tr><td>90</td><td>orientation (rotation angle), both caption and contents</td></tr><tr bgcolor="#DDDDDD"><td>always</td><td>precedence over stored floats</td></tr><tr><td>force</td><td>per se here</td></tr><tr bgcolor="#DDDDDD"><td>forcesplit</td><td>per se here(For TABLES only) split tables</td></tr>
</table>
(table copied from the manual)
<{{cmd>|placefigure</cmd> }} and <{{cmd>|placetable</cmd> }} also accept the same set of options, and allow to create floating figures and captions respectively.
'''reference'''
If you don't need to refer to your float, you can leave this parameter out.
== Examples ==I will explain the examples in terms of <{{cmd>|placefigure</cmd> }} but the same set of options are also valid for other floats.
* If you do not want a caption
 
<texcode>
\placefigure[none] {} {\externalfigure[figurename]}
</texcode>
 
 
* If you do not want the figure to be numbered (but still want the caption)
 
<texcode>
\placefigure [nonumber] {caption} {\externalfigure[figurename]}
</texcode>
 
* Suppose you want the figure to be placed on the right side of the page, a few lines into the paragraph, and want the rest of the paragraph to wrap around the figure
 
<texcode>
\placefigure [right,2*line] {caption} {\externalfigure[figurename]}
</texcode>
 
or
 
<texcode>
\placefigure [right,2*hang] {caption} {\externalfigure[figurename]}
</texcode>
 
This does not work correctly at a page boundary. The <tt>line</tt> option leaves the space above the figures empty, while the <tt>hang</tt> option also wraps texts above the figure.
 
=Floats and columns=
 
This special case is discussed [[Columns#Floats_and_other_limitations_of_columns|here]].
 
=Floats on empty pages=
 
There’s a way to switch off page headings at full page floats:
 
<texcode>
\placefigure startplacefigure[title=Cow,location={nonepage,high,header} {] \externalfigure{figurename}}[cow.pdf]\stopplacefigure
</texcode>
=Protruding Floats in Double-Sided Documents= If you have a double-sided document with wide outer margins then you might want your figures to protrude into the margin. In a double-sided document you need to tell ConTeXt to decide whether to make the figure protrude to the left orthe right. This can be done as follows:
<texcode>
\placefiguredefinefloat[nonetextmarginfigure] {} [textmarginfigures]\setupfloat[textmarginfigure][location=inner]\placetextmarginfigure{\externalfigure{[figurename}]}
</texcode>
The following code gives a full example that can be pasted into live ConTeXt:
 
<texcode>
\setuppagenumbering [alternative=doublesided]
\setuplayout[location=middle,backspace=2pc, width=20pc]
\definefloat[textmarginfigure][textmarginfigures]
\setupfloat[textmarginfigure][location=inner]
\starttext
\input knuth
\placetextmarginfigure[here]{}{\externalfigure[figurename][width=30pc]}
\input knuth
\placetextmarginfigure[here]{}{\externalfigure[figurename][width=30pc]}
\input knuth
\stoptext
</texcode>
* If you do not want the figure to be numbered (but still want the caption)=Landscape Floats in a Portrait Document=
Wide tables, for example, can be turned and most likely will need to be put on a separate page.
<texcode>
\placefigure startplacetable [nonumber] location={page,90},title=Table caption} {] \bTABLE [textwidth=\textheight] put a wide table here... \eTABLE\externalfigure{figurename}}stopplacetable
</texcode>
Both the table caption and the contents will be rotated, but not the page header and footer which remain "upright". Notice that one must set the TABLE textwidth to {{cmd|textheight}} in order for the table macros to fit properly.
 
= Floats and section headings =
* Suppose you want By default, section headings don't wrap “around” floating objects. Instead, they will be moved down as far as needed to appear below the figure to float. This behaviour can be placed on controlled using the right side <tt>aligntitle</tt> option of the page{{cmd|setupheads}} or {{cmd|setuphead}} commands. = Captions = To change the style of figure(table) captions, use {{cmd|setupcaptions}}. To use a few lines into different (e.g. abbreviated) caption in the paragraphlist of floats, and want the rest of the paragraph to warp around the figureyou can do:
<texcode>
\placefigure startplacefigure[righttitle={A rather long caption},2*line] list={A short caption} {]This is the content of the actual figure\externalfigure{figurename}}stopplacefigure
</texcode>
or In MkII this was possible by:
<texcode>
\placefigure defineselector[caption][rightmax=2,n=2*hang] \starttext\setupselector[caption][n=1]\completelistoffigures\setupselector[caption][n=2]\placefigure[][]{\select{caption} {\externalfigureShort caption for list} {figurenameA rather longer caption which will appear below the figure itself}} {This is the content of the actual figure}\stoptext
</texcode>
This does not = Float Combinations = If you want correctly at to place floats besides each other or in a page boundary. The regular matrix,each with its own number and caption, you need a float combination: <ttcontext source=yes>line\useMPlibrary [dum] %% sample images \startplacefigure [location=none] % disable numbering of outer float \startfloatcombination [nx=2, ny=1] % two columns, one row \startplacefigure [title=Left] \externalfigure [dummy] \stopplacefigure \startplacefigure [title=Right] \externalfigure [dummy] \stopplacefigure \stopfloatcombination\stopplacefigure</ttcontext> options leaves  If you want only one number for the space above the figures emptywhole thing, you may use a regular combination within a float: <context source=yes>\useMPlibrary [dum] %% sample images \startplacefigure [title=My combination] \startcombination [nx=2, ny=1] \startcontent \externalfigure [dummy] \stopcontent \startcaption Left \stopcaption \startcontent \externalfigure [dummy] \stopcontent \startcaption Right \stopcaption \stopcombination\stopplacefigure</context>  See also {{cmd|startcombination}}, {{cmd|startfloatcombination}} and [[Combinations]]. = Subfloats =Subfloatnumbering creates subfigures sharing a mutual figure prefix and anindividual subfigure designator (e.g. figure 1a), figure 1b, while the etc.). The command {{cmd|startsubfloatnumbering}} is used for this. <ttcontext source=yes>hang\useMPlibrary [dum] %% sample images \startsubfloatnumbering \startplacefigure [title=Alpha] \externalfigure \stopplacefigure  \startplacefigure [title=Beta] \externalfigure \stopplacefigure\stopsubfloatnumbering</ttcontext> option  Subfloats can also wraps texts above the be used with floatcombinations: <context source=yes>\useMPlibrary [dum] %% sample images \startplacefigure [location=none] \startsubfloatnumbering \startfloatcombination [nx=2, ny=1] \startplacefigure [title=Left, reference=fig:left] \externalfigure \stopplacefigure \startplacefigure [title=Right, reference=fig:right] \externalfigure \stopplacefigure \stopfloatcombination \stopsubfloatnumbering\stopplacefigure See \in{figure}[fig:left] and \in{figure}[fig:right].</context>  See also {{cmd|startcombination}}, {{cmd|startfloatcombination}}, [[Combinations]] and {{cmd|startsubfloatcombination}}. = Flushing floats = The command {{cmd|placefloats}} outputs all pending floats[[Category:Basics]][[Category:Layout]]
69

edits

Navigation menu