Chapter 12
Ditto: Positioned Elements and Gifs

   12.1 Positioned Elements
   12.2 /Picture Comamnd
   12.3 Call to Specials of Gif
   12.4 The Environment of Gif
      With Char Map
      With Given Text and Inline Text
      File Name
      Counter
      Non-Html
   12.5 Utilities for Gif
      Disabled Math

<..gif..>
 \ifHtml <.html gif.>
 \fi
 -_-_-

12.1 Positioned Elements

<..shared config..>+
 \NewConfigure{Canvas}[3]{}
 -_-_-

% * can be replaced by any distinguished character 
% \special{ 
%    * before-all 
%    * after-all     %right  %left %height %depth 
%    * before-char   %x %y 
%    * after-char 
%    * line          %x %y %thickness %length 
%    * x-coefficients %A(x) + %B 
%    * y-coefficients %C(y) + %D 
% } 

<..html gif..>
 \def\Canvas{\ht:special{t4ht"}}
 \let\EndCanvas=\Canvas
 -_-_-

The attached source tries three renderings for ‘A�sub�x�/sub�’. My understanding of the positioning mechanism is that, in all three cases, the reference point for ‘x’ should be 0.7ex under the right leg of A. Moreover, the measurement 0.7ex should be with respect to the dimension of the font of A.

 
           /\ 
          /--\ 
         /    \........... 
                \/       } 0.7ex within font of A 
               ./\.......} 
 
 
                      A<SPAN 
STYLE="position:relative"><SPAN 
STYLE="position:absolute; top:0.7ex"><SPAN 
STYLE="font-size: 70% ;">x</SPAN></SPAN></SPAN> 

12.2 /Picture Comamnd

<..html gif..>+
 \def\:img{%
    \ifx       *\:temp  \let\:temp=\i:mgif \let\:next=\:GIf
    \else \ifx +\:temp  \let\:temp=\i:mgif \let\:next=\:Gif
    \else \ifx [\:temp  \let\:temp=\im:g
    \else               \def\:temp{\im:g[{\csname
                                         a:Picture-alt\endcsname}]}%
    \fi \fi \fi  \:temp}
 -_-_-

<..html config util..>+
 \NewConfigure{Picture-alt}{1}
 \Configure{Picture-alt}{}
 -_-_-

\Configure{Picture-alt} is for \Picture{...} commands; it provides the default content. The other two commands tell whether the bit maps and given alyternate values, respictively, are to be used. The are used, iff the argument has non empty value (the argument itself is not used).

Without the \leavevmode above, the start of paragraph can enter into the <IMG ..> tag.

Empty file name is a request for a default name of the form \jobname%\romannumeral \P:ctureCount.

<..gif..>+
 \def\P:ct{\leavevmode  \futurelet\:temp\:img}
 \let\Picture=\P:ct
 \def\yes:pic{\PictureOn}
 \def\no:pic{\PictureOff}
 -_-_-

12.3 Call to Specials of Gif

<..gif..>+
 \def\i:mgif#1{\futurelet\:temp\:gif}
 
 \def\:gif{%
    \ifx \:temp[\expandafter\:GifText
    \else       \expandafter\:next       \fi }
 -_-_-

The following macro is for imported pictures \Picture{....} and \Picture[...]{...}.

<..html gif..>+
 \def\xim:g[#1]#2{{\cond:pic{%
    \def\gif:nm{\edef\gif:nm}\gif:name{#2}%
    \expandafter\get:ext\gif:nm.<.par del.>%
    \edef\PictureFile{\gif:nm\ifx\:temp\empty \PictExt\fi}%
    \Needs-\PictureFile \ht:special{t4ht@-}%
    \a:IMG\ht:special{t4ht=\PictureFile}\b:IMG
    \a:PictureAlt{#1}\b:PictureAlt \d:IMG
    \a:PictureAttr{\at:IMG}\e:IMG}}\After:Picture}
 \def\noim:g[#1]#2{}
 \let\im:g=\xim:g
 -_-_-

<..html config util..>+
 \NewConfigure{PictureAlt}{2}
 \NewConfigure{PictureAttr}[1]{\def\a:PictureAttr##1{#1}}
 \Configure{PictureAlt} {\NoFonts} {\EndNoFonts}
 \Configure{PictureAttr} {\HCode{\Hnewline #1}}
 -_-_-

The following macro is for labeled bit pictures \Picture+{....} and \Picture*{...}.

<..html gif..>+
 \def\strt:gf#1#2{#2%
    \csname a:PictureAlt*+\endcsname
    \let\sv:sp\sp
    \let\sv:sb\sb
    \ifx \s:p\:UnDef \else \let\sp\s:p \fi
    \ifx \s:b\:UnDef \else \let\sb\s:b \fi
    \if #1!\ht:special{t4ht!\:AltPicture:}%
           \global\let\:AltPicture:=\empty  \fi  send to char map
    \ht:special{t4ht|}%
    \ht:special{t4ht++\PictureFile}%
    \iprt:special
 }
 \def\nd:gf#1#2{%
    \let\ht:special=\tex:special
    \ht:special{t4ht+}%
    \if #1!\ht:special{t4ht!}\fi    stop sending to char map
    \let\sp\sv:sp
    \let\sb\sv:sb
    \ht:special{t4ht|}%
    \csname b:PictureAlt*+\endcsname
    \ifx #2\relax \else \csname a:PictureAttr*+\endcsname{#2}\e:IMG\fi
 }
 \def\img:alt{\ht:special{t4ht@-}%
    \a:IMG\ht:special{t4ht=\PictureFile}\b:IMG}
 -_-_-

<..shared config..>+
 \NewConfigure{PictureAlt*+}{2}
 \NewConfigure{PictureAttr*+}[1]{%
    \expandafter\def\csname a:PictureAttr*+\endcsname##1{#1}%
 }
 \Configure{PictureAttr*+}{\ht:special{t4ht=#1}}
 -_-_-

flag ){ ‘<make a special for dvi driver‘> } 
  else switch( get_char() ){ 
     case ’+’: { ‘<out gif filename‘> 
     case ’@’: { ‘<write to lg file‘> break; } 
 
  case ’+’: { while( special_n-- > 0 )  (void) get_char();  break; } 
  case ’=’: Contribution of text (\’’\HCode’). 
  case ’<’: 
  case ’>’: { ‘<redirect html output‘>  break; } 
  case ’!’: { ‘<handle char map mode‘>  break; } 
  case ’|’: { gif_ch = !gif_ch;  break; } 
 
  case "..." : Positioned dvi code 
 
\item \‘’.extension for root file’ 
 
 
\item \‘’@@’ for char mode        (what is this????)  e.g., javascript 
\item \‘’@+’ for note to lg file  (where is this???) 
\item \‘’@-’ for removing left margins from char maps 
 
 
\HCode{<HR>} 
 
\item \‘’@%P’ --- On-off modes for traceing of POP, PUSH in DVI 
\item \‘’@%D’ --- On-off modes for traceing CHAR...RAHC in DVI 
\item \‘’@%H’ --- On-off modes for traceing h spaces 
\item \‘’@%V’ --- On-off modes for traceing v spaces 
\item \‘’@%R’ --- On-off modes for traceing x rulers 
 
 
In all the above, uppercase for plus, lowercase for minus 1 
 
\item \‘’@%%x...pre...x...post...’ --- Group tracing. 
    Default \‘’<!-- DVI ’ and \‘’\n-->’, where \’’\n’ represents 
    new line char (i.e., \‘’\Hnewline’). 
    \‘’x’ can be any character. if it is not there, 
    the postfix is assumed to be empty. 
\item \‘’@%...’ --- Not used, if not of the above format 
 
\HCode{<HR>} 
 
\item \‘’:+...’  increment by 1( define, if not defined) 
\item \‘’:-...’  decrement by 1 
\item \‘’:>...’  push current value 
\item \‘’:<...’  pop current value 
\item \‘’:!...’   display current value 
\item \‘’:|...’   display top value 
 
\item \‘’;-’ --- yes default font 
\item \‘’;+’ --- no default font 
\item \‘’;%’ --- insert font size 
\item \‘’;=’ --- insert css name of ch 
 
 
\item \‘’;i’ ---  i=1 (before ch-name),2 (between ch-name and ch),3 
    (after ch), 4 (before img-src), 5 (between img-src and alt), 6 
    (between alt and name), 7(after name). 
\item \‘’;8’ --- PauseFontStyle 
\item \‘’;9’ --- ContFontStyle 
 
\item \‘’~’ --- on/off for transport data to group boundaries 
\item \‘’~<....’ --- transport back 
\item \‘’~>....’ --- transport forward 
 

12.4 The Environment of Gif

<..html config util..>+
 \NewConfigure{IMG}{5}
 -_-_-

The third and forth parameters are separated by user cotributed attr-list.

<..html config util..>+
 \NewConfigure{Picture}[1]{\def\PictExt{#1}}
 \Configure{Picture}{.png}
 -_-_-

<..picture off..>
 \let\im:g=\noim:g
 -_-_-

<..picture on..>
 \let\im:g=\xim:g
 -_-_-

GIF:

PNG:

JPG:

With Char Map

Independent block: no brackets.

Resolution can be an integer number or a pair of integer numbers separated by a comma. The first for x-resolution, the second for y-resolution. Then we can have a map for boundary characters made up of pairs: character to be replaced followed by replcment.

For \Picture+{}: (no box, no pre)

<..html gif..>+
 \def\:Gif#1{\cond:pic{%
    \gif:name{#1}\csname a:Picture+\endcsname
    \strt:gf!\img:alt
    \def\EndPicture{\nd:gf!{\c:IMG\Pic:Img}%
       \let\EndPicture=\:UnDef \csname b:Picture+\endcsname
       \After:Picture}}}
 -_-_-

<..html config util..>+
 \NewConfigure{Picture+}{2}
 -_-_-

For \Picture*{}: Vertical box + pre. Might be a problem because vertical boxes assume the width of the page, and a few of them in a line may cause a picture to go out of the page boundaies—a problem for convert. If the content of the box is just a box, or boxes, as is the case in DraTeX, they the ebeded boxes induce the width. The \hfill\break may handle some of these cases.

\Picture*{}.....\EndPicture will go to \:GIf. \Picture*[..]{}.....\EndPicture will go to \:GifText.

<..html gif..>+
 \def\:GIf#1{\cond:pic{\ifvmode\vfill\break\else
       \ht:special{t4ht@[}\hfill\break.\ht:special{t4ht@]}\fi
    \gif:name{#1}\csname a:Picture*\endcsname
    \strt:gf!\img:alt
       \ifmmode \expandafter\vcenter\else \expandafter\vtop\fi
         \bgroup   \let\EndPicture=\:EndGIf  \NoHtmlEnv }}
 \def\:EndGIf{%
         \egroup \nd:gf!{\c:IMG \Pic:Img}\csname b:Picture*\endcsname
         \After:Picture}
 -_-_-

<..html config util..>+
 \NewConfigure{Picture*}{2}
 -_-_-

<..html gif..>+
 \def\After:Picture{\After:EndPicture
    \global\let\After:EndPicture=\empty}
 \let\After:EndPicture=\empty
 \def\AfterPicture#1{\append:def\After:EndPicture{#1}%
    \global\let\After:EndPicture=\After:EndPicture}
 -_-_-

<PRE>s force line breaks also in visual browsers, and we don’t want these breaks within formulas.

The \let\:Gif|=\:gobble is no good in the foolowing because it does not take care of the presence of \EndPicture. It is also not needed because \:Gif has \cond:pic to take care of it.

<..html gif..>+
 \def\iprt:special{%
    \def\ht:special##1{\tex:special{t4ht+##1}}}
 \let\tex:special=\ht:special
 -_-_-

With Given Text and Inline Text

\Picture*{}.....\EndPicture will go to \:GIf. \Picture+{}.....\EndPicture will go to \:Gif. \Picture*[..]{}.....\EndPicture will go to \:GifText with \:next=\:GIf. \Picture+[..]{}.....\EndPicture will go to \:GifText with \:next=\:Gif.

Given text: [non empty]. Inline text: [].

The following macro is for imported pictures \Picture*+{....} and \Picture*+[...]{...}.

<..html gif..>+
 \def\x:GifText[#1]#2{\cond:pic{%
    \ifx \:next\:GIf
       \def\gif:box{\vtop\bgroup \NoHtmlEnv \let\gif:box=\egroup}%
    \else  \let\gif:box=\empty  \fi
    \gif:name{#2}%
    \img:alt  \def\:temp{#1}%
    \ifx \:temp\empty \else
        \csname a:PictureAlt*+[]\endcsname
            {#1}\csname b:PictureAlt*+[]\endcsname\fi
    \ht:special{t4ht>\jobname.tmp}%                    dump
    \strt:gf-\empty  \gif:box
    \def\EndPicture{%
      \gif:box  \nd:gf-\relax  \ht:special{t4ht<\jobname.tmp}%
      \csname a:PictureAttr*+[]\endcsname{\c:IMG\Pic:Img}\e:IMG
      \After:Picture}%
 }}
 \let\:GifText=\x:GifText
 \def\no:GifText[#1]{\:gobble}
 -_-_-

<..shared config..>+
 \NewConfigure{PictureAlt*+[]}{2}
 \NewConfigure{PictureAttr*+[]}[1]{%
    \expandafter\def\csname a:PictureAttr*+[]\endcsname##1{#1}%
 }
 \Configure{PictureAlt*+[]} {\NoFonts} {\EndNoFonts}
 \Configure{PictureAttr*+[]} {\ht:special{t4ht=#1}}
 -_-_-

<..html gif..>+
 \ifx \:DraCatCodes\:UnDef
    <.set basic Pic:Img.>
 \fi
 -_-_-

<..set basic Pic:Img..>
 \def\Pic:Img{\at:IMG}
 -_-_-

The \everypar{t4ht="#1"} can’t be

CHECK ISSUE OF ATTRIBUTES FOR IMAGES

<..picture off..>+
 \let\:GifText=\no:GifText
 -_-_-

<..picture on..>+
 \let\:GifText=\x:GifText
 -_-_-

File Name

We have a command of the form \gif:name{file-name attributes}

<..html gif..>+
 \def\gif:name#1{\edef\at:IMG{\noexpand\get:gfnm#1 <.par del.>}\at:IMG}
 -_-_-

The material within the if is for eliminating the extra space introduced before |<par del|>.

<..html gif..>+
 \def\get:gfnm#1 #2<.par del.>{\def\at:IMG{#2}%
    \ifx \at:IMG\empty\else
       \expandafter\aT:IMG\at:IMG<.par del.>%
    \fi
    \gif:nm{#1}}
 \def\aT:IMG#1 <.par del.>{\def\at:IMG{#1}}
 -_-_-

It used to be as follows, which caused extra space at end of arguments.

\def\gif:name#1{\edef\at:IMG{\noexpand\get:gfnm#1 |<par del|>}\at:IMG} 
\def\get:gfnm#1 #2|<par del|>{\def\at:IMG{#2}\gif:nm{#1}} 
 

<..html gif..>+
 \def\NextPictureFile{\def\Next:PictureFile}
 \NextPictureFile{}
 \def\gif:nm#1{%
    \gHAdvance\P:ctureCount by 1
    \xdef\PictureFile{#1}\ifx  \PictureFile\empty
       \xdef\PictureFile{\Next:PictureFile}\fi
    \global\let\Next:PictureFile=\empty
    \ifx  \PictureFile\empty
       \bgroup  \Advance:\P:ctureCount by -\Pic:Cnt
       \xdef\PictureFile{\j:bname<.tail for file name.>\P:ctureCount
                         x\Pic:Dm\PictExt}%
       \egroup
    \else
       \expandafter\get:ext\PictureFile.<.par del.>%
       \ifx\:temp\empty \xdef\PictureFile{\PictureFile\PictExt}\fi
    \fi
    \immediate\write-1{l. \the\inputlineno\space Writing
                  \jobname.idv[\P:ctureCount] (\PictureFile)}%
    }%
 -_-_-

<..html gif..>+
 \def\SavePicture#1{\def\:tempa{#1}\SaveP:cture}
 \Odef\SaveP:cture[#1]{%
    \edef\:tempb{\noexpand\Odef\expandafter\noexpand\:tempa[####1]{{%
       \let\noexpand\Log:Needs=\noexpand\:gobble
       \noexpand\Picture[\HCode{#1}]{\PictureFile\space####1}}}}%
    \:tempb \expand:after{\global\expandafter\let\:tempa=}\:tempa }
 -_-_-

Without the \HCode{#1} above things like --&gt; expand. Why the \HCode is not a problem?

<..html gif..>+
 \def\NewPictureDomain#1{%
    \global\let\Pic:Cnt=\P:ctureCount
    \def\Pic:Dm{#1} \ifx \Pic:Dm\empty
       \xdef\Pic:Dm{\P:c:Dm}%
       \gHAdvance\P:c:Dm   by 1
    \fi }
 \HAssign\P:c:Dm = 0
 \let\Pic:Dm=\empty
 \HAssign\Pic:Cnt=1
 -_-_-

Counter

<..html gif..>+
 \HAssign\P:ctureCount=0
 \let\:AltPicture:=\empty        100 = default size
 -_-_-

Non-Html

Don’t do \let\EndPicture=\relax. Within \PictureOff it is treated as undefined.

12.5 Utilities for Gif

In \pic:cond\a\b the \b refers to the command to be used when already within a gif-picture. The \a is to be used if a gif-picture is to be opened.

<..html gif..>+
 \def\pic:gobble{\ifx \EndPicture\:UnDef \else \expandafter\:gobble\fi}
 \def\pic:gobbleII{\ifx \EndPicture\:UnDef \else \expandafter\:gobbleII\fi}
 \def\nopic:gobble#1{\ifx \EndPicture\:UnDef \else #1\fi}
 \def\pic:cond#1#2{%
    \ifx\EndPicture\:UnDef \def\end:condpic{\EndPicture}\expandafter#1%
    \else                  \let\end:condpic=\empty  \expandafter#2%
    \fi }
 \def\cond:pic#1{%
    \ifx \EndPicture\:UnDef #1\else
       \let\E:pic=\EndPicture \PushMacro\E:pic
       \def\EndPicture{\PopMacro\E:pic \let\EndPicture=\E:pic}\fi}
 -_-_-

Disabled Math

Global on and off for some reason fails sometimes.

<..html gif..>+
 \def\PictureOff{%
    \expandafter\let\csname Pic:\Pic:On\endcsname=\EndPicture
    \ifx \EndPicture\:UnDef   \let\EndPicture=\empty \fi
    <.picture off.>%
    \Advance:\Pic:On by 1 }
 \def\PictureOn{%
    \ifnum \Pic:On>0
      \Advance:\Pic:On by -1
      \ifnum \Pic:On=0  <.picture on.>%
      \fi
      \expand:after{\let\EndPicture=}\csname Pic:\Pic:On\endcsname
      \ifx \EndPicture\relax \let\EndPicture=\:UnDef\fi
    \else
      \:warning{\string\PictureOn\space without \string\PictureOff}%
    \fi }
 \HAssign\Pic:On = 0
 -_-_-

Don’t go directly for \PushMacro\EndPicture, just in case the user wants to use this stack.

Smash is most often used to produce comples patterns, so let su go and make them pictures.

<..html gif..>+
 \def\:temp#1{\ifx \EndPicture\:Undef
       \relax\ifmmode\hbox{$#1$}\else \hbox{#1}\fi
    \else \o:smash:{#1}\fi}
 \HLet\smash=\:temp
 -_-_-

The definition \def\HCode#1{\leavevmode\special{t4ht=#1}} can be problematic for grouping in pictures because of the \leavevmode that in immediate environment produces some side code.

It looks like the following problems, or most of them, have been resolved with a fix to \noalign.

The \openup10pt causes too much space in [some pictures]and too much memory in [others]Putting a \offinterlineskip solves sometimes the problem in some pictures of getting too much vertical spcace, but may create [improper pictures] with depth and hiehgt 0 (put in TeX4ht1.sty the picture in box0 and measure). The problem is because \def\offinterlineskip{\baselineskip-1000\p@ \lineskip\z@ \lineskiplimit\maxdimen} puts too much space in \lineskiplimit.