ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Vertical alignment of framed text
       [not found] <mailman.5106.1176811855.17432.ntg-context@ntg.nl>
@ 2007-04-17 13:27 ` Vyatcheslav Yatskovsky
  2007-04-17 19:49   ` Wolfgang Schuster
  2007-04-18 17:29   ` Mojca Miklavec
  0 siblings, 2 replies; 10+ messages in thread
From: Vyatcheslav Yatskovsky @ 2007-04-17 13:27 UTC (permalink / raw)
  To: ntg-context-request@ntg.nl

Hello,

I want to insert "hotkeys", surrounded by a round frame, into a paragraph text. I almost have achieve it, except of proper vertical alignment.

Now it is the frame that is aligned with the text bottom line. But, I want the text inside a frame to be aligned with the rest of line. 

(I found that \vcenter solves the problem but I don't know how to merge it with \defineframed. Or, maybe there is better solution?)


\defineframed
   [hotkey][height=\lineheight,offset=4pt,corner=00]

\starttext
Another way to start or stop the device is to use hotkey. If the application is active (that is, sits on the foreground of your desktop),  the hotkey is {\hotkey{Space}}. If it is not active, then use global hotkey -- \hotkey{Alt}+\hotkey{Space}.
\stoptext


-- 
Best regards,
Vyatcheslav Yatskovsky

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Vertical alignment of framed text
  2007-04-17 13:27 ` Vertical alignment of framed text Vyatcheslav Yatskovsky
@ 2007-04-17 19:49   ` Wolfgang Schuster
  2007-04-17 22:46     ` Vyatcheslav Yatskovsky
  2007-04-18 17:29   ` Mojca Miklavec
  1 sibling, 1 reply; 10+ messages in thread
From: Wolfgang Schuster @ 2007-04-17 19:49 UTC (permalink / raw)
  To: ntg-context; +Cc: mailing list for ConTeXt users, Yatskovsky

On Tue, 17 Apr 2007 16:27:03 +0300
Vyatcheslav Yatskovsky <yatskovsky@gmail.com> wrote:

> \defineframed
>    [hotkey][height=\lineheight,offset=4pt,corner=00]

Hi,

\defineframed
   [hotkey][offset=4pt,corner=00,location=low]

Wolfgang

> 
> \starttext
> Another way to start or stop the device is to use hotkey. If the application is active (that is, sits on the foreground of your desktop),  the hotkey is {\hotkey{Space}}. If it is not active, then use global hotkey -- \hotkey{Alt}+\hotkey{Space}.
> \stoptext

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Vertical alignment of framed text
  2007-04-17 19:49   ` Wolfgang Schuster
@ 2007-04-17 22:46     ` Vyatcheslav Yatskovsky
  2007-04-19 12:05       ` Peter Rolf
  0 siblings, 1 reply; 10+ messages in thread
From: Vyatcheslav Yatskovsky @ 2007-04-17 22:46 UTC (permalink / raw)
  To: Wolfgang Schuster; +Cc: ntg-context-request@ntg.nl


[-- Attachment #1.1: Type: text/plain, Size: 1221 bytes --]

Hello,

Thank you Wolfgang, but 

\defineframed
   [hotkey][offset=4pt,corner=00,location=low]

produces too big frames, while

\defineframed
   [hotkey][height=\lineheight,offset=4pt,corner=00,location=low]

produces nice tight frames but places the text very BELOW the line text. (Previously the text was too much ABOVE).

If I remove offset then it looks good (on center), except I really want more right/left spacing (from the inner text to the frame) but less spacing top/below, so that It resembles a keyboard key. 

How to get just center position while keeping the frame tight and more X-stretched?


> On Tue, 17 Apr 2007 16:27:03 +0300
> Vyatcheslav Yatskovsky <yatskovsky@gmail.com> wrote:

>> \defineframed
>>    [hotkey][height=\lineheight,offset=4pt,corner=00]

> Hi,

> \defineframed
>    [hotkey][offset=4pt,corner=00,location=low]

> Wolfgang


>> \starttext
>> Another way to start or stop the device is to use hotkey. If the application is active (that is, sits on the foreground of your desktop),  the hotkey is {\hotkey{Space}}. If it is not active, then use global hotkey -- \hotkey{Alt}+\hotkey{Space}.
>> \stoptext


-- 
Best regards,
Vyatcheslav Yatskovsky

[-- Attachment #1.2: Type: text/html, Size: 3894 bytes --]

[-- Attachment #2: Type: text/plain, Size: 139 bytes --]

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Vertical alignment of framed text
  2007-04-17 13:27 ` Vertical alignment of framed text Vyatcheslav Yatskovsky
  2007-04-17 19:49   ` Wolfgang Schuster
@ 2007-04-18 17:29   ` Mojca Miklavec
       [not found]     ` <6faad9f00704190819t559de7afgce3ae41e8b5f9815@mail.gmail.com>
  1 sibling, 1 reply; 10+ messages in thread
From: Mojca Miklavec @ 2007-04-18 17:29 UTC (permalink / raw)
  To: Yatskovsky, mailing list for ConTeXt users

On 4/17/07, Vyatcheslav Yatskovsky wrote:
> Hello,
>
> I want to insert "hotkeys", surrounded by a round frame, into a paragraph text. I almost have achieve it, except of proper vertical alignment.
>
> Now it is the frame that is aligned with the text bottom line. But, I want the text inside a frame to be aligned with the rest of line.
>
> (I found that \vcenter solves the problem but I don't know how to merge it with \defineframed. Or, maybe there is better solution?)
>
>
> \defineframed
>    [hotkey][height=\lineheight,offset=4pt,corner=00]
>
> \starttext
> Another way to start or stop the device is to use hotkey. If the application is active (that is, sits on the foreground of your desktop),  the hotkey is {\hotkey{Space}}. If it is not active, then use global hotkey -- \hotkey{Alt}+\hotkey{Space}.
> \stoptext

Perhaps \inframed could solve your problem? It takes case for proper
baseline placement.

There is no \defineinframed equivalent (perhaps there should be
some?), but you can still define it in the old TeX-ish way:
    \def\hotkey#1{\inframed[corner=00]{\ #1\ }}

Offset is a bit tricky: \framed only supports a single set of offset
parameters (you cannot set left/right/top/bottom offset separately).
Wolfgang (Schuster) has written a patch for leftoffset/rightoffset,
but if it's not (until it's not) part of the core, you can still add
fake space before or after the text if you're using framed with a
\def-ined command.

\inframed[height=\lineheight] doesn't work properly. (It might be a
bug, an oversight or simply something that you're not supposed to use
anyway ;)

Mojca

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Vertical alignment of framed text
  2007-04-17 22:46     ` Vyatcheslav Yatskovsky
@ 2007-04-19 12:05       ` Peter Rolf
  0 siblings, 0 replies; 10+ messages in thread
From: Peter Rolf @ 2007-04-19 12:05 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Vyatcheslav,

Vyatcheslav Yatskovsky wrote:
> Hello,
> 
> 
> Thank you Wolfgang, but 
> 
> 
> \defineframed
> 
>    [hotkey][offset=4pt,corner=00,location=low]
> 
> 
> produces too big frames, while
> 
> 
> \defineframed
> 
>    [hotkey][height=\lineheight,offset=4pt,corner=00,location=low]
> 
> 
> produces nice tight frames but places the text very BELOW the line text.
> (Previously the text was too much ABOVE).
> 
> 
> If I remove offset then it looks good (on center), except I really want
> more right/left spacing (from the inner text to the frame) but less
> spacing top/below, so that It resembles a keyboard key. 
> 
> 
> How to get just center position while keeping the frame tight and more
> X-stretched?
>
the best way is to define your own macro, as \framed alone can't handle
this special case. if you insert an \offset macro inside \framed (with
offset=overlay to avoid additional offsets), you can use different
offset values for all directions.

you still have to lower the result, so you also need

\dontleavehmode\lower??ex\hbox{<Hotkey>}

in your final macro.

something like (untested!)

\def\Hotkey#1%
  {\dontleavehmode\lower??ex\hbox
   {\framed[offset=overlay,corner=00,...]
    {\offset[leftoffset=??em, rightoffset=??em,
       topoffset=??ex, bottomoffset=??ex]
     {#1\strut}}}}

try to use em for horizontal offsets and ex for vertical ones (instead
of fixed values). also metapost generated backgrounds (overlay) look
much better here.

happy fiddling with all the ?? ;)

peter

> 
> 
>> On Tue, 17 Apr 2007 16:27:03 +0300
> 
>> Vyatcheslav Yatskovsky <yatskovsky@gmail.com
> <mailto:yatskovsky@gmail.com>> wrote:
> 
> 
>>> \defineframed
> 
>>>    [hotkey][height=\lineheight,offset=4pt,corner=00]
> 
> 
>> Hi,
> 
> 
>> \defineframed
> 
>>    [hotkey][offset=4pt,corner=00,location=low]
> 
> 
>> Wolfgang
> 
> 
> 
>>> \starttext
> 
>>> Another way to start or stop the device is to use hotkey. If the
> application is active (that is, sits on the foreground of your desktop),
>  the hotkey is {\hotkey{Space}}. If it is not active, then use global
> hotkey -- \hotkey{Alt}+\hotkey{Space}.
> 
>>> \stoptext
> 
> 
> 
> -- 
> 
> Best regards,
> 
> Vyatcheslav Yatskovsky
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Vertical alignment of framed text
       [not found]       ` <6faad9f00704190838h1d11d3c3q1e29d10a46f859ed@mail.gmail.com>
@ 2007-04-19 17:42         ` Vyatcheslav Yatskovsky
  2007-04-19 18:23           ` Mojca Miklavec
  2007-04-19 18:24           ` Aditya Mahajan
  0 siblings, 2 replies; 10+ messages in thread
From: Vyatcheslav Yatskovsky @ 2007-04-19 17:42 UTC (permalink / raw)
  To: Mojca Miklavec; +Cc: ntg-context-request@ntg.nl

Hello Mojca,

Is there need for \strut at all? The definitions

\def\hotkey#1{\inframed[corner=00, offset=0pt]{\ #1\ }}

and 

\def\hotkey#1{\inframed[corner=00,offset=0pt]{\strut\ #1\ }}

work equally well and I can see no difference.

I (wrongly) supposed that \strut version can prevent the frame from growing in height, but when I set offset more then zero, the height is increased too.

In your original version, only the offset option was omitted, so that  frames was bigger by default. With offset=0pt they look just pretty.
(Until there are possibility to control width/height or xoffset/yoffset separately). 

Thanks a lot.

Best, 
Vyatcheslav



> On 4/19/07, Mojca Miklavec <mojca.miklavec.lists@gmail.com> wrote:
>> Hello Hans,

>> I've found the following sentence in core-rul.tex:

>> %D The last conditional takes care of the special situation of
>> %D in||line \inframed[height=3cm]{framed} boxes. Such boxes have
>> %D to be \inframed{aligned} with the running text.

>> But the behaviour seems either broken or perhaps I didn't understand
>> the concept. The text inside bigger \inframed command doesn't seem to
>> be aligned properly:

>> The last conditional takes care of the special situation of in||line
>> \inframed[height=3cm]{framed} boxes. Such boxes have to be
>> \inframed{aligned} with the running text.

>> Thanks a lot,
>>     Mojca

>> PS to Yatskovsky: I didn't realize that \inframed was indeed only a
>> synonym for "location=low".

> The culprit most probably lies here:

> \installframedlocator \v!low
>   {}
>   {\doprelocframedbox\strutdp
>    \setbox\framebox\hbox{\lower\scratchdimen\box\framebox}%
>    \ht\framebox\strutht
>    \dp\framebox\strutdp
>    \box\framebox}

> The box is lowered for "strut depth" + line width + offset, without
> taking the extra parameter "height=..." into account.


> For Yatskovsky: you can still use something like
>     \def\hotkey#1{\inframed[corner=00,offset=5pt]{\strut\ #1\ }}
> if you need to have bigger offset (offset=...) and if you want all
> your hotkeys to be equally heigh (\strut, although I believe that
> strut is already there by default).

> But the "forgotten case" could or should still be solved ...

> Mojca

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Vertical alignment of framed text
  2007-04-19 17:42         ` Vyatcheslav Yatskovsky
@ 2007-04-19 18:23           ` Mojca Miklavec
  2007-04-19 18:24           ` Aditya Mahajan
  1 sibling, 0 replies; 10+ messages in thread
From: Mojca Miklavec @ 2007-04-19 18:23 UTC (permalink / raw)
  To: Yatskovsky; +Cc: mailing list for ConTeXt users

On 4/19/07, Vyatcheslav Yatskovsky wrote:
> Hello Mojca,
>
> Is there need for \strut at all? The definitions

No. You get it by default unless you explicitely disable it. I just
didn't understand why you wanted to set the height explicitely.

> \def\hotkey#1{\inframed[corner=00, offset=0pt]{\ #1\ }}
>
> and
>
> \def\hotkey#1{\inframed[corner=00,offset=0pt]{\strut\ #1\ }}
>
> work equally well and I can see no difference.
>
> I (wrongly) supposed that \strut version can prevent the frame from growing in height, but when I set offset more then zero, the height is increased too.

Strut only prevents frame from shinking, not from growing. It's just
an invisible placeholder. If you provide higher material, the box will
grow.

> In your original version, only the offset option was omitted, so that  frames was bigger by default. With offset=0pt they look just pretty.
> (Until there are possibility to control width/height or xoffset/yoffset separately).
>
> Thanks a lot.
>
> Best,
> Vyatcheslav
>
>
>
> > On 4/19/07, Mojca Miklavec <mojca.miklavec.lists@gmail.com> wrote:
> >> Hello Hans,
>
> >> I've found the following sentence in core-rul.tex:
>
> >> %D The last conditional takes care of the special situation of
> >> %D in||line \inframed[height=3cm]{framed} boxes. Such boxes have
> >> %D to be \inframed{aligned} with the running text.
>
> >> But the behaviour seems either broken or perhaps I didn't understand
> >> the concept. The text inside bigger \inframed command doesn't seem to
> >> be aligned properly:
>
> >> The last conditional takes care of the special situation of in||line
> >> \inframed[height=3cm]{framed} boxes. Such boxes have to be
> >> \inframed{aligned} with the running text.
>
> >> Thanks a lot,
> >>     Mojca
>
> >> PS to Yatskovsky: I didn't realize that \inframed was indeed only a
> >> synonym for "location=low".
>
> > The culprit most probably lies here:
>
> > \installframedlocator \v!low
> >   {}
> >   {\doprelocframedbox\strutdp
> >    \setbox\framebox\hbox{\lower\scratchdimen\box\framebox}%
> >    \ht\framebox\strutht
> >    \dp\framebox\strutdp
> >    \box\framebox}
>
> > The box is lowered for "strut depth" + line width + offset, without
> > taking the extra parameter "height=..." into account.
>
>
> > For Yatskovsky: you can still use something like
> >     \def\hotkey#1{\inframed[corner=00,offset=5pt]{\strut\ #1\ }}
> > if you need to have bigger offset (offset=...) and if you want all
> > your hotkeys to be equally heigh (\strut, although I believe that
> > strut is already there by default).
>
> > But the "forgotten case" could or should still be solved ...
>
> > Mojca

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Vertical alignment of framed text
  2007-04-19 17:42         ` Vyatcheslav Yatskovsky
  2007-04-19 18:23           ` Mojca Miklavec
@ 2007-04-19 18:24           ` Aditya Mahajan
  1 sibling, 0 replies; 10+ messages in thread
From: Aditya Mahajan @ 2007-04-19 18:24 UTC (permalink / raw)
  To: Yatskovsky, mailing list for ConTeXt users

On Thu, 19 Apr 2007, Vyatcheslav Yatskovsky wrote:

> Hello Mojca,
>
> Is there need for \strut at all? The definitions
>
> \def\hotkey#1{\inframed[corner=00, offset=0pt]{\ #1\ }}
>
> and
>
> \def\hotkey#1{\inframed[corner=00,offset=0pt]{\strut\ #1\ }}
>
> work equally well and I can see no difference.
>
> I (wrongly) supposed that \strut version can prevent the frame from growing in height, but when I set offset more then zero, the height is increased too.

\strut insures that all frames are of a minimimum height equal the 
height of parenthesis. Try

\hotkey{A} \hotkey{a}

Aditya


> In your original version, only the offset option was omitted, so that  frames was bigger by default. With offset=0pt they look just pretty.
> (Until there are possibility to control width/height or xoffset/yoffset separately).
>
> Thanks a lot.
>
> Best,
> Vyatcheslav
>
>
>
>> On 4/19/07, Mojca Miklavec <mojca.miklavec.lists@gmail.com> wrote:
>>> Hello Hans,
>
>>> I've found the following sentence in core-rul.tex:
>
>>> %D The last conditional takes care of the special situation of
>>> %D in||line \inframed[height=3cm]{framed} boxes. Such boxes have
>>> %D to be \inframed{aligned} with the running text.
>
>>> But the behaviour seems either broken or perhaps I didn't understand
>>> the concept. The text inside bigger \inframed command doesn't seem to
>>> be aligned properly:
>
>>> The last conditional takes care of the special situation of in||line
>>> \inframed[height=3cm]{framed} boxes. Such boxes have to be
>>> \inframed{aligned} with the running text.
>
>>> Thanks a lot,
>>>     Mojca
>
>>> PS to Yatskovsky: I didn't realize that \inframed was indeed only a
>>> synonym for "location=low".
>
>> The culprit most probably lies here:
>
>> \installframedlocator \v!low
>>   {}
>>   {\doprelocframedbox\strutdp
>>    \setbox\framebox\hbox{\lower\scratchdimen\box\framebox}%
>>    \ht\framebox\strutht
>>    \dp\framebox\strutdp
>>    \box\framebox}
>
>> The box is lowered for "strut depth" + line width + offset, without
>> taking the extra parameter "height=..." into account.
>
>
>> For Yatskovsky: you can still use something like
>>     \def\hotkey#1{\inframed[corner=00,offset=5pt]{\strut\ #1\ }}
>> if you need to have bigger offset (offset=...) and if you want all
>> your hotkeys to be equally heigh (\strut, although I believe that
>> strut is already there by default).
>
>> But the "forgotten case" could or should still be solved ...
>
>> Mojca
>
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
>
>
>

-- 
Aditya Mahajan | EECS Systems, University of Michigan
http://www.eecs.umich.edu/~adityam | Ph: 734.262.4008

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Vertical alignment of framed text
  2007-04-19 12:46 ` Vyatcheslav Yatskovsky
@ 2007-04-29 10:52   ` Peter Münster
  0 siblings, 0 replies; 10+ messages in thread
From: Peter Münster @ 2007-04-29 10:52 UTC (permalink / raw)
  To: ConTeXt list

On Thu, 19 Apr 2007, Vyatcheslav Yatskovsky wrote:

> The ideal solution would be 
> 
> \def\hotkey#1{\inframed[corner=00, location=low, height=\lineheight]{\ #1\ }}
> 
> but it doesn't work. Maybe it is a bug, ideed?

What about:

\setupcolors[state=start]
\def\hotkey#1{\inframed[background=screen,offset=overlay,
  height=\lineheight,corner=00]{~#1~}}

(this is what I am using)

Cheers, Peter

-- 
http://pmrb.free.fr/contact/
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Vertical alignment of framed text
       [not found] <mailman.5172.1176934612.17432.ntg-context@ntg.nl>
@ 2007-04-19 12:46 ` Vyatcheslav Yatskovsky
  2007-04-29 10:52   ` Peter Münster
  0 siblings, 1 reply; 10+ messages in thread
From: Vyatcheslav Yatskovsky @ 2007-04-19 12:46 UTC (permalink / raw)
  To: ntg-context-request@ntg.nl; +Cc: Mojca Miklavec

Hello,

Please, don't take me as too much exacting man, but Mojca's (partial) solution

\def\hotkey#1{\inframed[corner=00]{\ #1\ }}

is more suitable for me than the Wolfgangs's (complete) one:

\defineframed
  [dohotkey]
  [strut=yes,corner=00,frameoffset=-0.2em,location=low]
\definehspace[hotkey][0.6em]
\def\hotkey#1{\dohotkey{\hspace[hotkey]#1\hspace[hotkey]}}   

The latter add space between surrounding words proportionally to the in-frame space.

The ideal solution would be 

\def\hotkey#1{\inframed[corner=00, location=low, height=\lineheight]{\ #1\ }}

but it doesn't work. Maybe it is a bug, ideed?

Best,
Vyatcheslav

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-04-29 10:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.5106.1176811855.17432.ntg-context@ntg.nl>
2007-04-17 13:27 ` Vertical alignment of framed text Vyatcheslav Yatskovsky
2007-04-17 19:49   ` Wolfgang Schuster
2007-04-17 22:46     ` Vyatcheslav Yatskovsky
2007-04-19 12:05       ` Peter Rolf
2007-04-18 17:29   ` Mojca Miklavec
     [not found]     ` <6faad9f00704190819t559de7afgce3ae41e8b5f9815@mail.gmail.com>
     [not found]       ` <6faad9f00704190838h1d11d3c3q1e29d10a46f859ed@mail.gmail.com>
2007-04-19 17:42         ` Vyatcheslav Yatskovsky
2007-04-19 18:23           ` Mojca Miklavec
2007-04-19 18:24           ` Aditya Mahajan
     [not found] <mailman.5172.1176934612.17432.ntg-context@ntg.nl>
2007-04-19 12:46 ` Vyatcheslav Yatskovsky
2007-04-29 10:52   ` Peter Münster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).