ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Using \startalign outside of math mode?
@ 2009-08-28 11:29 Matthijs Kooijman
  2009-08-28 11:57 ` Matthijs Kooijman
  2009-08-28 14:31 ` Aditya Mahajan
  0 siblings, 2 replies; 3+ messages in thread
From: Matthijs Kooijman @ 2009-08-28 11:29 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

Hi,

I'm using a custom pretty printer to apply some formatting to a buffer.
However, I'm not using a monospaced font, but some sans serif font to display
the result. In the original text, I have some lines that are nicely aligned
using leading spaces. For example:

  foo = bar
      | baz

Obviously, when using a non monospaced font for this, the alignment is lost.
When in math mode, I can use \startalign to force alignment, like: 

  \startalign
  foo \NC= bar
      \NC| baz
  \stopalgin

However, I haven't manage to switch to math mode inside pretty printed text.
Also, even if I would, I would get my text rendered in math mode, which
probably won't work.

So, I'm wondering if there is anything like \startalign to use outside of math
mode? I've been looking at the implementation of \startalign, but couldn't
find it...

Some way to insert spacing until some fixed point (e.g. tab-stop like) would
probably work, if I can define the tabstop on a case by case basis?

Gr.

Matthijs

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

___________________________________________________________________________________
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] 3+ messages in thread

* Re: Using \startalign outside of math mode?
  2009-08-28 11:29 Using \startalign outside of math mode? Matthijs Kooijman
@ 2009-08-28 11:57 ` Matthijs Kooijman
  2009-08-28 14:31 ` Aditya Mahajan
  1 sibling, 0 replies; 3+ messages in thread
From: Matthijs Kooijman @ 2009-08-28 11:57 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

Hi all,

>    foo = bar
>        | baz

it seems I found some sort of a solution. Using the \setwidthof I found at
[1], I wrote the following:


  \def\setwidthof#1\to#2%
  {\bgroup
  \setbox\scratchbox\hbox{#1}%
  \expanded{\egroup\def\noexpand#2{\the\wd\scratchbox}}}

  foo = bar
  \setwidthof{foo }\to\alignwidth
  \hskip\alignwidth| baz

This works, but is not so pretty, obviously. Since I'm using a custom pretty
printer, I can probably hack something up that generates this from the more
natural form automatically. Still, I'm wondering if there are more pretty
methods to do this. In particular, this method is completely limited to
indents at the start of a line (e.g., aligning the b's of bar and baz isn't
possible, though I could perhs do more complicated math using the width of
"| ", but that will become even more hideous...

Any other suggestions?

Gr.

Matthijs

[1]: http://www.ntg.nl/pipermail/ntg-context/2009/037404.html

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

___________________________________________________________________________________
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] 3+ messages in thread

* Re: Using \startalign outside of math mode?
  2009-08-28 11:29 Using \startalign outside of math mode? Matthijs Kooijman
  2009-08-28 11:57 ` Matthijs Kooijman
@ 2009-08-28 14:31 ` Aditya Mahajan
  1 sibling, 0 replies; 3+ messages in thread
From: Aditya Mahajan @ 2009-08-28 14:31 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Fri, 28 Aug 2009, Matthijs Kooijman wrote:

> Hi,
>
> I'm using a custom pretty printer to apply some formatting to a buffer.
> However, I'm not using a monospaced font, but some sans serif font to display
> the result. In the original text, I have some lines that are nicely aligned
> using leading spaces. For example:
>
>  foo = bar
>      | baz
>
> Obviously, when using a non monospaced font for this, the alignment is lost.
> When in math mode, I can use \startalign to force alignment, like:
>
>  \startalign
>  foo \NC= bar
>      \NC| baz
>  \stopalgin
>
> However, I haven't manage to switch to math mode inside pretty printed text.
> Also, even if I would, I would get my text rendered in math mode, which
> probably won't work.
>
> So, I'm wondering if there is anything like \startalign to use outside of math
> mode? I've been looking at the implementation of \startalign, but couldn't
> find it...

Startalign is essentially a table with some predefined defaults. You can 
try something like (untested)

\starttable[|rs(0.2em)|cs(0.2em)|l|]
  \NC foo \NC = \NC bar \NC \AR
  \NC     \NC | \NC baz \NC \AR
\stoptable

Aditya
___________________________________________________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2009-08-28 14:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-28 11:29 Using \startalign outside of math mode? Matthijs Kooijman
2009-08-28 11:57 ` Matthijs Kooijman
2009-08-28 14:31 ` Aditya Mahajan

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).