Changes

Jump to navigation Jump to search
2,964 bytes added ,  20:24, 27 June 2021
m
effect of struct added
< [[Visuals]] |
 
 
{{todo|the page devoted to all kinds of framed stuff}}
 
= How to achieve specific results =
== Preventing hyphenation ==
One can prevent hyphenation inside a frame by passing <{{code>|1=nothypenated</code> }} option to <{{code>|1=align</code>}}. It is also a good idea to add <{{code>|1=verytolerant</code> }} and <code>strectch</{{code> |1=stretch}} options.
<context source="yes">
\setuppapersize[A5]
\startcombination[2*2]
{\framed
== Specify the width no longer than needed ==
I want to specify the maximum width of a frame. If the size of the box is smaller than the maximum width, I want a tight box. This can be done using the <{{code>|1=autowidth=force</code> }} option to framed.
<context source="yes">
\setuppapersize[A5]
\defineframed
[tightframed][width=5cm,autowidth=force,align=middle]
== Ruled Frames ==
<{{cmd>|framed</cmd> }} allows you to specify specific edges to be ruled.As an alternative to <{{code>|1=frame=on</code> }} (the default), one can specify<{{code>|1=topframe=on</code>}}, etc.
Note that, as the default is to draw a complete frame,
it is necessary to either specify the state (on/off) for all four edges
or include the keyword <{{code>|1=frame=off</code>}}.
<context source="yes">
\setuppapersize[A5]
\framed[frame=off,topframe=on,leftframe=on]{A fancy title}
</context>
The thickness of the frame rule can be specified using <{{code>|1=rulethickness=</code>}}
<context source="yes">
\setuppapersize[A5]
\framed[frame=off,leftframe=on,rulethickness=2pt]{\tfa\bf A fancy title}
</context>
== Rounded Corners ==
<{{cmd>|framed</cmd> }} allows you to have round corners with <{{code>|1=corner=round</code>}}. There are also other possibilities if you want round corners but not at all places by giving an appropriate number to <{{code>|1=corner=...</code>}}. This example is taken from [[source:core-rul.tex | core-rul.tex]] and each frame is typeset using
<texcode>
<context>
\setuppapersize[A5]
\dontleavehmode\framed
[corner=0,frame=on,
{\tttf corner=\twodigits\recurselevel}%
\quad}
 
</context>
== Coloring frame background and framed text ==
First you have to turn on colors with <{{cmd>|setupcolors</cmd><tt>|2=[state=start]</tt>}}. Then you can define the background and foreground (=text) colors:
<texcode>\framed[background=color,backgroundcolor=....,foreground=color,foregroundcolor=...]{...}</texcode>
If you want to make the frame itself disappear, add a <tt>{{code|1=frame=off</tt> }} to the setups.
{|
{\tfxx \bf Rounded corners with offset}
</context>
|For filling frames with offset you have to add options <{{code>|1=frameoffset=..., backgroundoffset=...</code>}}
<texcode>
\framed
|}
See the [[ColorsColor]] section article for more information on available colors and color usage.
== Shaded background for part of a displayed equation ==
To highlight part of a formula, you can give it a gray background using <{{cmd>|mframed</cmd>}}:
<context source="yes">
\setuppapersize[A5]
\setupcolors[state=start]
\def\graymath{\mframed[frame=off,
</context>
The <cmd>{{code|,</cmd> }} add a tiny bit of space to prevent the gray background from crowding the equals and plus sign.
== Inline Frames ==
The command <{{cmd>|inframed</cmd>}}, similar to <{{cmd>|framed</cmd>}},
differs in the definition of the baseline:
<context source="yes">
\setuppapersize[A5]
\framed[frame=off,width=10em,align=flushleft]{%
Notice the difference between
<context source="yes">
\setuppapersize[A5]
\usemodule[tikz]%
\tikzstyle{block}=[rectangle,draw=black,text centered,style=dotted,inner sep=0pt]
\Picture{sample/cow.pdf}{All your base are belong to us}{SampleRef}
\stoptext
</context>
 
 
== Colorored horizontal stripe of full paper width ==
 
<context mode="mkiv" source="yes">
\definepapersize[sheet][width=120mm,height=60mm]
\setuppapersize[sheet]
\setuppagenumbering[location=]
\setuplayout
[width=110mm,
backspace=5mm,
topspace=5mm,
header=5mm,
headerdistance=5mm,
footer=5mm,
footerdistance=5mm]
 
\showframe
 
\setupbackgrounds[page] [background=color, backgroundcolor=lightgray]
 
\startuniqueMPgraphic{whatever}
fill OverlayBox
leftenlarged BackSpace rightenlarged CutSpace
withcolor OverlayColor;
setbounds currentpicture to OverlayBox enlarged max(BackSpace,CutSpace);
\stopuniqueMPgraphic
 
\defineoverlay[whatever][\uniqueMPgraphic{whatever}]
\starttext
 
Here some text first.
 
\framed[background=whatever,backgroundcolor=green,frame=off,width=\textwidth]{test}
 
After, again some text.
 
\stoptext
 
</context>
= Width broad and local =
Sometimes <tt>{{code|1=width</tt> }} must be adapted to a "local" <tt>{{code|1=\hsize </tt>}}
(the actual text area used by TeX to determine line breaks).
For example:
<context source='yes'>
\setuppapersize[A5]
\setuppapersize[A7,landscape][A7,landscape]
\setupbodyfont[8pt,ss]
</context>
Here we use <tt>{{code|1=\setlocalhsize</tt> }} after <tt>{{code|1=\startitemize</tt> }} to setup the localhsize:
<context source="yes">
\setuppapersize[A5]
\setuppapersize[A7,landscape][A7,landscape]
\setupbodyfont[8pt,ss]
=Spacing between frame and text=
<tt>\{{cmd|framed</tt> }} comes with two different types of offsets:
one for the frame itself and another for the its content.
The parameters <tt>{{code|1=frameoffset</tt> }} and <tt>{{code|1=backgroundoffset</tt>}}
were already explained above in the section [[#Coloring frame background and framed text]].
==Content offsets==
Beyond those there is another four dimensions that enable you to control
the safety distance of a <tt>\{{cmd|framed</tt>}}’s content by orientation.Horizontally, <tt>{{code|1=loffset</tt> }} governs the left, <tt>{{code|1=roffset</tt> }} the right
offset;
the same goes for <tt>{{code|1=boffset</tt> }} for the bottom and <tt>{{code|1=toffset</tt> }} for
the top distance.
Their effects are explored in the following example (MkIV only).
hoffset=\zeropoint]
</texcode>
 
= Location parameter =
 
<context source="yes">
\ruledhbox
{A
\framed[width=2cm,align=middle,location=hanging]{location\\equals\\hanging}
\framed[width=2cm,align=middle,location=depth] {location\\equals\\depth}
\framed[width=2cm,align=middle,location=height] {location\\equals\\height}
B}
\vskip2cm
\ruledhbox
{A
\framed[width=2cm,align=middle,location=low] {location\\equals\\low}
\framed[width=2cm,align=middle,location=line] {location\\equals\\line}
\framed[width=2cm,align=middle,location=high] {location\\equals\\high}
B}
\vskip2cm
\ruledhbox
{A
\framed[width=2cm,align=middle,location=top] {location\\equals\\top}
\framed[width=2cm,align=middle,location=bottom] {location\\equals\\bottom}
\framed[width=2cm,align=middle,location=lohi] {location\\equals\\lohi}
\framed[width=2cm,align=middle,location=middle] {location\\equals\\middle}
B}
</context>
 
and to compare with basic height and depth of the line, and looking at the end on the effect of the struct parameter:
 
<context source="yes">
\defineframed[MonCadre][width=1.75cm,align=middle]
\define[1]\DemoLoc{\ruledhbox{%
{\getbuffer \MonCadre[location=#1]
{location\\ \color[darkmagenta]{\bf #1}\\location}}}}
\setupbodyfont[10pt]
%\showboxes
\startbuffer
\blackrule[height=max,depth=0pt,width=3mm]%
\blackrule[height=0pt,depth=max,width=3mm]
\stopbuffer
 
\strut
\DemoLoc{empty} \dontleavehmode
\DemoLoc{keep} \dontleavehmode
\DemoLoc{depth} \dontleavehmode
\DemoLoc{bottom} \dontleavehmode
\DemoLoc{low}
\blank[big]
\strut
\DemoLoc{middle} \dontleavehmode
\DemoLoc{lohi} \dontleavehmode
\DemoLoc{line}
\blank[big]
\strut
\DemoLoc{top} \dontleavehmode
\DemoLoc{height} \dontleavehmode
\DemoLoc{high} \dontleavehmode
\DemoLoc{formula} \dontleavehmode
\DemoLoc{hanging}
 
\setupframed[MonCadre][strut=yes]
\strut
{\tt strut=yes}
\DemoLoc{bottom} \dontleavehmode \DemoLoc{top}
 
{\tt strut=no}
\setupframed[MonCadre][strut=no]
\DemoLoc{bottom} \dontleavehmode \DemoLoc{top}
</context>
= Similar topics =
= See also =
* ... [[:Category:Command/Frames]]
[[Category:Frames]][[Category:ConTeXt-IssuesBasics]]

Navigation menu