On Tuesday 02 July 2002 6:52 am, Andre Poenitz wrote:
> On Mon, Jul 01, 2002 at 08:06:34PM +0100, Angus Leeming wrote:
> > I'm trying to use David's preview.sty so that we can generate all the
> > previews in one go when the document is loaded. Much quicker than running
> > a script on each one.

Specifically, it doesn't block LyX as badly at start-up.

> Actually I think that's the only time we need to batch things. During
> "normal operation" the preview generation seems to be fast enough to be
> done one by one, so maybe we don't need that fullfledged "run queue" at
> all.

I'm of the same opinion; we need this only when a document is loaded. But we 
still need to dump the preamble if we're to get user-defined macros et al.

I've tried to define a converter that can be used by both the batch processor 
and by the image loader. Ie, it'll work for both multiple and single images.

> > I guess that the latter task is a question of setting gs' -r option using
> > the info
> > \screen_dpi 95
> > \screen_zoom 130
> >
> > -r124 ?
>
> I need a factor of 2 here with 95 and 150. That's not the conventional
> multiplication...

Where's the 150 come from? That's 130 to you: 95 * 1.3 = 123.5.

Anyway, I've attached the tex file that LyX would generate (include 
foreground and background color info) and the shell script that would convert 
it to a stack of PPM files.

sh conv.sh trial.tex 123.5

We need to split Buffer::makeLaTeXFile into two so that we can just grab the 
preamble. Thereafter, the PreambleQueue class is finished too I believe.

Angus


%% LyX 1.2 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[10pt,twocolumn,english]{article}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{geometry}
\geometry{verbose,a4paper,lmargin=0.5in,rmargin=0.5in,headheight=-1in}
\setlength\parskip{\medskipamount}
\setlength\parindent{0pt}
\usepackage{graphicx}
\usepackage[authoryear]{natbib}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\providecommand{\LyX}{L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@}
%% Bold symbol macro for standard LaTeX users
\newcommand{\boldsymbol}[1]{\mbox{\boldmath $#1$}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
%% Turn off page numbering
\let\ps@plain\ps@empty
\ps@empty

%% The spacing between columns in two-column mode
\setlength{\columnsep}{0.5 in}

%% Set the sections to be bold but otherewise the same size
%% as normal text
\renewcommand\section{\@startsection {section}{1}{\z@}%
                                   {\parskip}%
                                   {\parskip}%
                                   {\normalfont\bfseries}}

%% Print the References title in uppercase
%% To get this to work we _have_ to load babel first.
\usepackage{babel}
\AtBeginDocument{\renewcommand\refname{REFERENCES}}

\usepackage{babel}

\makeatother

\usepackage[active,dvips,tightpage]{preview}

\AtBeginDocument{\AtBeginDvi{%
  \special{!userdict begin/bop-hook{//bop-hook exec
     <000000faf0e6>{255 div}forall setrgbcolor
     clippath fill setrgbcolor}bind def end}}}

\begin{document}
\begin{preview}
$D'$
\end{preview}

\begin{preview}
\[
E\left(0\right)-E\left(\kappa \right)\propto \sqrt{\kappa }^{1-D'}\]
\end{preview}

\begin{preview}
$\kappa $ 
\end{preview}

\begin{preview}
\[
\frac{\partial }{\partial t}\left[E\left(0\right)-E\left(t\right)\right]\propto 
\sqrt{\kappa }^{1-3D'}\]
\end{preview}



\end{document}

Attachment: conv.sh
Description: application/shellscript

%%
%% This is file `preview.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% preview.dtx  (with options: `style')
%% preview.dtx  (with options: `style,active')
%% 
%% IMPORTANT NOTICE:
%% 
%% For the copyright see the source file.
%% 
%% Any modified versions of this file must be renamed
%% with new filenames distinct from preview.sty.
%% 
%% For distribution of the original source see the terms
%% for copying and modification in the file preview.dtx preview.dtx.
%% 
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%%\iffalse
%%     preview.dtx for extracting previews from LaTeX documents.  Part of
%%     the preview-latex package.
%%     Copyright (C) 2001, 2002 David Kastrup
%%
%%     This program is free software; you can redistribute it and/or modify
%%     it under the terms of the GNU General Public License as published by
%%     the Free Software Foundation; either version 2 of the License, or
%%     (at your option) any later version.
%%
%%     This program is distributed in the hope that it will be useful,
%%     but WITHOUT ANY WARRANTY; without even the implied warranty of
%%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%%     GNU General Public License for more details.
%%
%%     You should have received a copy of the GNU General Public License
%%     along with this program; if not, write to the
%%     Free Software Foundation, Inc., 59 Temple Place, Suite 330,
%%     Boston, MA 02111-1307  USA
%%\fi
\NeedsTeXFormat{LaTeX2e}
\def\reserved@a #1#2$#3: #4${\edef#1{\reserved@c #2#4 $}}
\def\reserved@c #1 #2${#1}
\reserved@a\reserved@b $Name: rel-0-7-2b $
\ifx\reserved@b\@empty
   \reserved@a\reserved@b CVS-$Revision: 1.57 $
\else
   \begingroup
      \lccode`-=`.
      \def\next rel-{}
      \edef\next{\lowercase{\endgroup
          \def\noexpand\reserved@b{\expandafter\next\reserved@b}}}
   \next
\fi
\reserved@a\next $Date: 2002/04/13 02:05:25 $
\edef\next{\noexpand\ProvidesPackage{preview}%
  [\next\space preview-latex \reserved@b]}
\next
\let\ifPreview\iffalse
\let\preview@delay=\@gobble
\let\pr@advise=\@gobbletwo
\def\pr@advise@ship#1#2#3{}
\def\pr@loadcfg#1{\InputIfFileExists{#1.cfg}{}{}}
\DeclareOption{noconfig}{\let\pr@loadcfg=\@gobble}
\def\pr@addto@front#1#2{%
  \toks@{#2}\toks@\expandafter{\the\expandafter\toks@#1}%
  \xdef#1{\the\toks@}}
\DeclareOption{active}{%
  \let\ifPreview\iftrue
  \def\pr@advise#1{%
    \expandafter\pr@adviseii\csname pr@\string#1\endcsname#1}%
  \def\pr@advise@ship#1#2#3{\pr@advise#1{\pr@protect@ship{#2}{#3}}}%
  \let\preview@delay\@firstofone}
\def\pr@adviseii#1#2#3{\preview@delay{%
  \ifx#1\relax \let#1#2\fi
  \toks@{#3#1}\edef#2{\the\toks@}}}
\DeclareOption{delayed}{%
  \ifPreview \def\preview@delay{\AtBeginDocument}\fi
}
\newif\ifpr@fixbb
\pr@fixbbfalse
\DeclareOption{psfixbb}{\ifPreview%
  \pr@fixbbtrue
  \newbox\pr@markerbox
  \setbox\pr@markerbox\hbox{\special{psfile=/dev/null}\fi}%
}
\DeclareOption{dvips}{%
  \preview@delay{\AtBeginDvi{%
    \special{!userdict begin/bop-hook{/isls false def%
    /vsize 792 def/hsize 612 def}def end}}}}
\begingroup
\catcode`\*=11
\@firstofone{\endgroup
\DeclareOption{displaymath}{%
  \preview@delay{\toks@{%
      \pr@startbox{\noindent$$%
        \aftergroup\pr@endbox\@gobbletwo}{$$}\@firstofone}%
    \everydisplay\expandafter{\the\expandafter\toks@
      \expandafter{\the\everydisplay}}}%
  \pr@advise@ship\equation{\begingroup\aftergroup\pr@endbox
    \def\dt@ptrue{\m@ne=\m@ne}\noindent}
    {\endgroup}%
  \pr@advise@ship\equation*{\begingroup\aftergroup\pr@endbox
    \def\dt@ptrue{\m@ne=\m@ne}\noindent}
    {\endgroup}%
}}
\begingroup
\def\next#1#2{%
\endgroup
    \DeclareOption{textmath}{%
      \preview@delay{\ifx#1\@undefined \let#1=$\fi
        \catcode`\$=\active}%
      \pr@advise@ship\(\pr@endaftergroup{}% \)
      \pr@advise@ship#1{\let#1=#2%
         \pr@setmathhooks{##1\everymath##1\everydisplay}}{}}}
\lccode`\~=`\$
\lowercase{\expandafter\next\expandafter~}%
  \csname pr@\string$\endcsname
\DeclareOption{graphics}{%
  \PreviewMacro[{*[[!}]{\includegraphics}}
\DeclareOption{floats}{%
  \PreviewSnarfEnvironment[![]{@float}%
  \PreviewSnarfEnvironment[![]{@dblfloat}}
\DeclareOption{sections}{%
  \PreviewMacro[!!!!!!*[!]{\@startsection}}
\DeclareOption*
   {\InputIfFileExists{pr\CurrentOption.def}{}{\OptionNotUsed}}
\def\PreviewMacro{\@ifstar\pr@starmacro\pr@macro}
\newcommand*\pr@macro[2][]{%
   \pr@advise@ship{#2}{\pr@callafter\pr@endbox#1\pr@endparse}{}}
\def\pr@protect@star#1{\pr@protect{%
    \pr@callafter\pr@seq!#1\pr@endparse\pr@stargobble}}
\def\pr@stargobble#1\pr@seq{}
\newcommand*\pr@starmacro[2][]{\pr@advise#2{\pr@protect@star{#1}}}
\def\PreviewEnvironment{\@ifstar\pr@starenv\pr@env}
\newcommand*\pr@starenv[2][]{\toks@{\pr@starmacro[{#1}]}%
  \the\expandafter\toks@\csname#1\endcsname
  \expandafter\pr@starmacro\csname end#1\endcsname}
\newcommand*{\pr@env}[2][]{\expandafter\pr@advise@ship
   \csname #2\endcsname{\begingroup\aftergroup\pr@endbox}{\endgroup}}
\newcommand*{\PreviewSnarfEnvironment}[2][]{%
  \expandafter\pr@advise
   \csname #2\endcsname{\pr@snarfafter#1\pr@endparse}%
 \expandafter\pr@advise
   \csname end#2\endcsname{\endgroup}}
\let\pr@ship@start\@empty
\let\pr@ship@end\@empty
\newenvironment{preview}{\ignorespaces}{\unskip}
\newenvironment{nopreview}{\ignorespaces}{\unskip}
\ProcessOptions\relax
\ifPreview\else\expandafter\endinput\fi
%%\iffalse
%%     preview.dtx for extracting previews from LaTeX documents.  Part of
%%     the preview-latex package.
%%     Copyright (C) 2001, 2002 David Kastrup
%%
%%     This program is free software; you can redistribute it and/or modify
%%     it under the terms of the GNU General Public License as published by
%%     the Free Software Foundation; either version 2 of the License, or
%%     (at your option) any later version.
%%
%%     This program is distributed in the hope that it will be useful,
%%     but WITHOUT ANY WARRANTY; without even the implied warranty of
%%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%%     GNU General Public License for more details.
%%
%%     You should have received a copy of the GNU General Public License
%%     along with this program; if not, write to the
%%     Free Software Foundation, Inc., 59 Temple Place, Suite 330,
%%     Boston, MA 02111-1307  USA
%%\fi
\newif\ifpr@outer
\pr@outertrue
\newcount\pr@snippet
\global\pr@snippet=1
\def\pr@protect{\ifx\protect\@typeset@protect
  \ifpr@outer \expandafter\expandafter\expandafter
     \@secondoftwo\fi\fi\@gobble}
\def\pr@protect@ship{\pr@protect{\@firstoftwo\pr@startbox}%
   \@gobbletwo}
\newbox\pr@box
\def\pr@startbox#1#2{%
  \ifpr@outer
    \toks@{#2}%
    \edef\pr@cleanup{\the\toks@}%
    \setbox\pr@box\vbox\bgroup
    \break
    \pr@outerfalse\@arrayparboxrestore
    \expandafter\expandafter\expandafter
    \pr@ship@start
    \expandafter\@firstofone
  \else
     \expandafter \@gobble
  \fi{#1}}
\def\pr@endbox{%
   \ifvmode \edef\reserved@a{\the\everypar}%
      \ifx\reserved@a\@empty\else
            \dimen@\prevdepth
            \noindent\par
            \setbox\z@\lastbox\unskip\unpenalty
            \prevdepth\dimen@
            \setbox\z@\hbox\bgroup\penalty-\maxdimen\unhbox\z@
              \ifnum\lastpenalty=-\maxdimen\egroup
              \else\egroup\box\z@ \fi\fi\fi
   \ifhmode \par\unskip\setbox\z@\lastbox
     \nointerlineskip\hbox{\unhbox\z@\/}%
   \else \unskip\unpenalty\unskip \fi
   \egroup
   \setbox\pr@box\vbox{%
       \baselineskip\z@skip \lineskip\z@skip \lineskiplimit\z@
       \@begindvi
       \nointerlineskip
       \splittopskip\z@skip\setbox\z@\vsplit\pr@box to\z@
       \unvbox\z@
       \nointerlineskip
       \color@setgroup
       \box\pr@box
       \color@endgroup}%
   \pr@ship@end
   {\let\protect\noexpand
   \voffset=-\ht\pr@box
   \hoffset=\z@
   \c@page=\pr@snippet
   \pr@shipout
   \ifpr@fixbb\hbox{%
     \dimen@\wd\pr@box
     \@tempdima\ht\pr@box
     \@tempdimb\dp\pr@box
     \box\pr@box
     \llap{\raise\@tempdima\copy\pr@markerbox\kern\dimen@}%
     \lower\@tempdimb\copy\pr@markerbox}%
   \else \box\pr@box \fi}%
   \global\advance\pr@snippet\@ne
   \pr@cleanup
}
\let\pr@shipout=\shipout
\def\shipout{\deadcycles\z@\setbox\z@\box\voidb@x\setbox\z@}
\def\pr@callafter{%
  \afterassignment\pr@parseit
  \let\pr@seq= }
\def\pr@parseit#1{\csname pr@parse#1\endcsname}
\let\pr@endparse=\@percentchar
\expandafter\def\csname pr@parse*\endcsname#1\pr@endparse#2{%
  \@ifstar{\pr@parseit#1\pr@endparse{#2*}}%
          {\pr@parseit#1\pr@endparse{#2}}}
\expandafter\def\csname pr@parse[\endcsname#1\pr@endparse#2{%
  \@ifnextchar[{\pr@bracket#1\pr@endparse{#2}}%
               {\pr@parseit#1\pr@endparse{#2}}}
\def\pr@bracket#1\pr@endparse#2[#3]{\pr@parseit#1\pr@endparse{#2[{#3}]}}
\expandafter\let\csname pr@parse]\endcsname=\pr@parseit
\def\pr@parse#1\pr@endparse#2#3{%
  \pr@parseit#1\pr@endparse{#2{#3}}}
\expandafter\let\csname pr@parse!\endcsname=\pr@parse
\expandafter\def\csname pr@parse\pr@endparse\endcsname#1{#1\pr@seq}
\def\pr@endaftergroup#1{#1\aftergroup\pr@endbox}
\def\pr@setmathhooks#1{\def\reserved@a##1{#1}%
  \def\reserved@b##1{##1{\the##1}}%
  \def\reserved@c##1{%
    ##1{\reserved@a\reserved@b\aftergroup\noexpand\pr@endbox
        \noexpand\the##1}}%
   \edef\reserved@a{\reserved@a\reserved@c}\reserved@a}
\def\pr@snarfafter{\ifpr@outer
     \pr@ship@start
     \let\pr@ship@start\@empty
   \fi
  \pr@callafter\pr@startsnarf}
\def\pr@startsnarf{\begingroup
   \pr@startbox{\begingroup\aftergroup\pr@endbox}{\endgroup}%
   \ignorespaces}
\renewenvironment{preview}{\begingroup
   \pr@startbox{\begingroup\aftergroup\pr@endbox}%
               {\endgroup}%
   \ignorespaces}%
   {\unskip\endgroup}
\renewenvironment{nopreview}{\pr@outerfalse\ignorespaces}{\unskip}
\nofiles
\output{\def\@elt#1{\global\setbox#1=\box\voidb@x}%
  \@currlist
  \@elt{255}%
  \let\@elt\relax
  \xdef\@freelist{\@currlist\@freelist}%
  \global\let\@currlist\@empty
  \deadcycles\z@}
\pr@loadcfg{prdefault}
\endinput
%%
%% End of file `preview.sty'.

Reply via email to