1

I was thinking about an experimental e-book layout that would use embedded scrolling text boxes for what would essentially function as really long margin- or footnotes in relation to a main text.

Say, for example, a page split into two columns, with the main text on the left and two text boxes of even height on the right (each with a bunch of text in it that the reader could scroll and read as desired).

Would it be possible to create an electronic document of some kind using LaTeX that would function this way? Perhaps something that could be exported to HTML (maybe with some HTML-specific commands in latex2html?) that could then be translated into a functional e-book? Is there a way to do it without HTML?

I realize this might be a pedestrian question but I've never used LaTeX in conjunction with HTML, or even if it would ever under any circumstances be appropriate to use HTML to write an e-book.

At any rate, any ideas?

4

Update More flexible version

OP wants solution with various number of scroll boxes. My idea is to provide command which declares new LaTeX box to which can then be added some material. So document can look like:

\documentclass{article}
\usepackage{lipsum}
\usepackage{infoboxes}
\newinfobox{dialogues}
\newinfobox{second}
\begin{document}

    Some text, blah blah\footnote{hello} bla bla\footnote{\lipsum[2]}

    \lipsum[2-8]

    \addtoinfobox{dialogues}{Hello \emph{world}}
    \addtoinfobox{dialogues}{Another line}
    \addtoinfobox{second}{\lipsum[3-9]}
    Another text\footnote{world}. %And now some\marginpar{Margin note. \lipsum[3-4]}

\end{document} 

Two scroll (info) boxes are used dialogues and second. Any material can be added with \addtoinfobox macro. I think good idea is to create some macros which would hide this interface and which call \addtoinfobox only when tex4ht is running, otherwise print information directly to text, or to margin notes.

Package infoboxes.sty

\ProvidesPackage{infoboxes}

\RequirePackage{etoolbox}
\newcounter{infoboxescnt}
\newcounter{tempinfbx}
\newcommand\newinfobox[1]{%
    \stepcounter{infoboxescnt}
    \expandafter\newbox\csname #1infobx\endcsname
    \listcsgadd{@usedinfboxes}{#1}
}

\newcommand\addtoinfobox[2]{%
    \global\expandafter\setbox\csname #1infobx\endcsname=\vtop\bgroup
    \expandafter\ifvoid\csname #1infobx\endcsname%
    \else\expandafter\unvbox\csname #1infobx\endcsname\fi#2\egroup
}

\newcommand\a@prntfbx[1]{}
\newcommand\b@prntfbx[1]{}
\newcommand\printinfobox[1]{\a@prntfbx{#1}\expandafter\copy\csname #1infobx\endcsname\b@prntfbx{#1}}

\newcommand\printinfoboxes{%
    \setcounter{tempinfbx}{0}
    \renewcommand\do[1]{%
        \typeout{Print info box: ##1}
        \stepcounter{tempinfbx}
        \printinfobox{##1}
    }
  \dolistcsloop{@usedinfboxes}
    %\forcsvlist{\if\relax\detokenize{##1}\relax Prazdny\else##1\fi}{\@usedinfboxes}
}

\endinput

and package for tex4ht, infoboxes.4ht

\def\LeavePar{\ifvmode\IgnorePar\fi \EndP}

\NewConfigure{printinfobox}{2}
\renewcommand\a@prntfbx[1]{\def\:bxname{#1}\a:printinfobox}
\renewcommand\b@prntfbx[1]{\b:printinfobox}

\Configure{printinfobox}{\IgnorePar\HCode{
<div class="infobox \:bxname">\Hnewline}\ShowPar}{\EndP\HCode{</div>}}

\let\tmp:prtfbxs\printinfoboxes

\renewcommand\printinfoboxes{}

\NewConfigure{printinfoboxes}{2}

\newcommand\mathexpression[1]{
    \strip@pt\dimexpr #1\relax
}

\newcommand\my:prntnfbxs{%
 \setcounter{tempinfbx}{0} 
 \renewcommand\do[1]{%
   \printinfobox{##1}\relax
   \Css{%
     .##1{margin-left:66\%;
     height:\mathexpression{1pt / \value{infoboxescnt} * 100}\%;
     top:\mathexpression{\value{tempinfbx}pt * 1 / \value{infoboxescnt} * 100}\%;
     }
   }
   \stepcounter{tempinfbx}
 }
 \dolistcsloop{@usedinfboxes} 
}
\Configure{@BODY}
  {\LeavePar
   \HCode{<article>\Hnewline}\par\ShowPar%
  }
\Configure{@/BODY}
  {\LeavePar
  \HCode{</article>\Hnewline}
  \par\ShowPar
\my:prntnfbxs
  }

\Css{article,.infobox{margin:0;padding:0;}}  
\Css{
article,.footnotes{width:66\%;}
}
\Css{
.infobox{
    width:33\%;
    float:right;
    margin-left:66\%;
    position:fixed;
    overflow:scroll;
}
}

Interesting part is

\renewcommand\do[1]{%
   \printinfobox{##1}\relax
   \Css{%
     .##1{margin-left:66\%;
     height:\mathexpression{1pt / \value{infoboxescnt} * 100}\%;
     top:\mathexpression{\value{tempinfbx}pt * 1 / \value{infoboxescnt} * 100}\%;
     }
   }
   \stepcounter{tempinfbx}
 }

which print all infoboxes in loop and for each it add css declaration with position and height information calculated from infoboxes count.

Compile with

htlatex sample "xhtml, fn-in"

you can see the result

Original answer

I don't think this is a good idea. E-books are usually read on devices with small screen, where whole area is filled with main content. Footnotes or sidenotes are usually placed either in standalone file with link from the text pointing to them, or directly after paragraph they appeared in, like in this epub3 sample. There is also problem that some e-book devices don't have touch interface and such box would be inaccessible.

But, if you really want to make such box, you can, of course. With tex4ht, you have option to put all footnotes into box placed bellow main text. With few lines of css, you can transform this box to scroll box sitting on the fixed place of the page.

Sample file sample.tex:

\documentclass{article}
\usepackage{lipsum}
\begin{document}

Some text, blah blah\footnote{hello} bla bla\footnote{\lipsum[2]}

\lipsum[2-8]

Another text\footnote{world}
\end{document} 

Config file with css instructions, scroll.cfg:

\Preamble{xhtml}
\begin{document}
\Css{
body{
width:35em;
margin-left:auto;
margin-right:auto;
}
}
\Css{
.footnotes{
   float:right;
   width:10em; 
   height:10em; 
   overflow:scroll;
   margin-left:42em;
   position:fixed;
   top:0;
}
}
\EndPreamble

compile with

htlatex sample "scroll, fn-in"

You can see the result here

Good thing is that clicking on the footnote number will scroll to corresponding footnote text.

  • Thank you, this is a great start! I understand your concerns. I had something slightly different in mind, though: (to slightly revise what I originally described), let's say the main body of text is two-thirds the width of the page, set on the left. In the remaining third on the right, I'd like to be able to put anywhere between two to four scrolling text boxes (each with heights of textheight divided by number of boxes) on any given page, stacked on top of each other. If you could please revise the example accordingly I would very much appreciate it. Thanks so far! – Isaac Apr 10 '13 at 9:05
  • ok, I understand it now better, I will try to modify my code – michal.h21 Apr 10 '13 at 9:16
  • Excellent, thank you. Also, apologies for lack of clarity before--for the sake of simplicity, rather than putting a footnote in a box, if you would be so kind as to revise the example as described above with the scrollboxes being something akin to standalone minipages or equivalent type of text box in the .3*textwidth margin, this would be EXACTLY what I was originally looking for. (Alternately, think of it as a two-column layout where the right column is populated entirely by the scrolling text boxes, if that makes sense). Thanks again! – Isaac Apr 10 '13 at 9:18
  • One example of how I might use this is, say, having the main body of text be a narrative, and having the scrolling text boxes be a series of dialogues between the characters through various electronic media, set beside some appropriate/corresponding point in the narrative...if that helps to conceptualize things. (Hence, not needing the actual footnotes.) – Isaac Apr 10 '13 at 9:28
  • Now I can see two solutions. First: you have two or three scroll boxes with dialogs, which are placed on fixed position of the page. Second: you have many scroll boxes which are placed placed next to text they are referring to, like margin notes. I think you want the second case, am I right? – michal.h21 Apr 10 '13 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.