ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Mojca Miklavec <mojca.miklavec.lists@gmail.com>
Subject: Hiding the content (drawing empty boxes?)
Date: Thu, 07 Jul 2005 23:45:24 +0200	[thread overview]
Message-ID: <42CDA274.6030503@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 877 bytes --]

Hello,

Some TeX challenge (probably not solvable?): for gurus only.

Is there a way to somehow

\starthidden
...
\stophidden,

which would leave exactly the same amount of blank space as if the 
content would be typeset?

Adam suggested to use transparent font colour, but this doesn't solve 
the problem as this won't stop the images, frames and nested 
\color[red]{font color changing commands} being displayed.

I tried to adapt the macro \demobox from the TeXBOOK which processes 
token by token and draws an empty box instead of that token. It works 
perfectly as long as there is only plain text between the braces, but as 
soon there is something more complex, it breaks. This behaviour is 
probably to be expected, but I have no idea how to let all the commands 
do what they are expected to do and only prohibit placing any boxes with 
some content.

Thanks,
	Mojca


[-- Attachment #2: demobox.tex --]
[-- Type: text/x-tex, Size: 2672 bytes --]


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% the portion of code adapted from the TeXBOOK, Excercise 11.5 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\dolist{\afterassignment\dodolist\let\next= }
\def\dodolist{\ifx\next\endlist\let\next\relax
  \else \\\let\next\dolist \fi
\next}
\def\endlist{\endlist}

\def\\{\if\space\next\ % assume that \next is unexpandable
\else\setbox0=\hbox{\next}\setbox1=\hbox{}%
  \dp1=\dp0\ht1=\ht0\wd1=\wd0\box1\fi}

\def\demobox#1{{\dolist#1\endlist}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\setupframed[strut=no,offset=0pt]
\setupcolors[state=start]
\starttext

%%%%%%%%%%%%%%
% this works %
%%%%%%%%%%%%%%

\color[blue]{This works OK:}

bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla \demobox{bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla} bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla

bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The examples below have some troubles %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\color[blue]{This is not 100\% properly aligned, but works:}\par
a\demobox{Tough exercise.}b\par
a\hbox{Tough exercise.}b\par
a\framed{\hbox{Tough exercise.}}b\par
a\framed{\demobox{Tough exercise.}}b\par
%a\demobox{\framed{Tough exercise.}}b\par % this doesn't work

a\externalfigure[cow]b\par
\color[blue]{This cow has shrinked:}\par
a\demobox{\externalfigure[cow]}b\par
a\framed{\externalfigure[cow]}b\par
\color[blue]{And this cow disappeared:}\par
a\framed{\demobox{\externalfigure[cow]}}b\par
% a\demobox{\framed{\externalfigure[cow]}}b\par % this doesn't work

\color[blue]{The commented stuff didn't even dare to compile.}

%\input tufte \demobox{{\input tufte }}\input tufte\par
%\input tufte \input tufte \input tufte

%\dorecurse{10}{bla }
%\demobox{\dorecurse{10}{bla }}
%\dorecurse{10}{bla }\par
%\dorecurse{10}{bla }
%\dorecurse{10}{bla }
%\dorecurse{10}{bla }

\stoptext


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

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

             reply	other threads:[~2005-07-07 21:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-07 21:45 Mojca Miklavec [this message]
2005-07-07 21:57 ` Hans Hagen
2005-07-07 22:33   ` Mojca Miklavec
2005-07-07 23:13     ` Adam Lindsay
2005-07-08  7:12       ` Hans Hagen
2005-07-08  8:40         ` Patrick Gundlach
2005-07-08  9:23         ` Adam Lindsay
2005-07-08 10:50           ` Mojca Miklavec
2005-07-08 12:33             ` Hans Hagen
2005-07-08 16:43               ` Mojca Miklavec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42CDA274.6030503@gmail.com \
    --to=mojca.miklavec.lists@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).