** support pdfpages via external inset **

* development/FORMAT:
* src/Buffer.cpp:
	- format incremented to 326

* src/LaTeXFeatures.cpp:
* lib/chkconfig.ltx:
* lib/doc/LaTeXConfig.lyx:
	- support pdfpages

* lib/external_templates:
	- add template for pdfpages

* lib/lyx2lyx/LyX.py:
* lib/lyx2lyx/lyx_1_6.py:
	- add reversion routine.

* lib/configure.py:
	- fix call to "pdftops --eps"

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24237 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2008-04-11 14:07:25 +00:00
parent 456e922dc1
commit 5997d41b38
9 changed files with 227 additions and 35 deletions

View File

@ -1,6 +1,9 @@
LyX file-format changes
-----------------------
2008-04-11 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* Format incremented to 326: support for pdflatex via external inset.
2008-03-29 Uwe Stöhr <uwestoehr@web.de>
* Format incremented to 325: merge the two Japanese languages to one that is
encoding independent.

View File

@ -246,6 +246,7 @@
\TestPackage{nicefrac}
\TestPackage{nomencl}
\TestPackage{pdfcolmk}
\TestPackage{pdfpages}
\TestPackage{prettyref}
\TestPackage{preview}
\TestPackage{rotating}

View File

@ -409,7 +409,7 @@ def checkConverterEntries():
checkProg('a PDF to PS converter', ['pdf2ps $$i $$o', 'pdftops $$i $$o'],
rc_entry = [ r'\converter pdf ps "%%" ""' ])
#
checkProg('a PDF to EPS converter', ['pdftops -eps $$i $$o'],
checkProg('a PDF to EPS converter', ['pdftops -eps -f 1 -l 1 $$i $$o'],
rc_entry = [ r'\converter pdf eps "%%" ""' ])
#
checkProg('a DVI to TXT converter', ['catdvi $$i > $$o'],

View File

@ -1,5 +1,5 @@
#LyX 1.6.0svn created this file. For more info see http://www.lyx.org/
\lyxformat 318
\lyxformat 325
\begin_document
\begin_header
\textclass article
@ -94,7 +94,7 @@ Found
\begin_inset Foot
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
The participating hosts in the Comprehensive TeX Archive Network are:
\end_layout
@ -110,7 +110,7 @@ ftp://ctan.tug.org/tex-archive
ftp://ftp.tex.ac.uk/tex-archive
\end_layout
\begin_layout PlainLayout
\begin_layout Plain Layout
There are also a zillion mirror sites which are listed at the three primary
sites.
\end_layout
@ -178,7 +178,7 @@ econfigure
\begin_inset Foot
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
or, if you want to change the system-wide settings, issue the command
\family typewriter
./configure
@ -245,7 +245,7 @@ arg "chk_fmtversion"
\begin_inset Foot
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
In case it is not clear to you, this number is the date at which the version
has been released.
\end_layout
@ -1004,7 +1004,10 @@ slides
\family sans
foils
\family default
instead if it is available (see\InsetSpace ~
instead if it is available (see
\begin_inset Space ~
\end_inset
\begin_inset CommandInset ref
LatexCommand ref
@ -1287,7 +1290,7 @@ FTP:
\begin_inset Flex URL
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
ftp://ftp.springer.de/pub/tex/latex/compsc/proc/author
\end_layout
@ -1356,7 +1359,7 @@ WWW:
\begin_inset Flex URL
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
http://www.sgmltools.org
\end_layout
@ -1423,7 +1426,7 @@ WWW:
\begin_inset Flex URL
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
http://www.dante.de
\end_layout
@ -1514,7 +1517,7 @@ WWW:
\begin_inset Flex URL
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
http://math.tulane.edu/~entcs/
\end_layout
@ -1845,7 +1848,7 @@ IEEEtran
\begin_inset Flex URL
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
http://www.ieee.org
\end_layout
@ -1906,7 +1909,7 @@ WWW: available from the site
\begin_inset Flex URL
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
http://www.worldscinet.com/ijmpc/mkt/guidelines.shtml
\end_layout
@ -1949,7 +1952,7 @@ WWW: available from the site
\begin_inset Flex URL
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
http://www.worldscinet.com/ijmpd/mkt/guidelines.shtml
\end_layout
@ -1992,7 +1995,7 @@ WWW: available from the site
\begin_inset Flex URL
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
ftp://ftp.iop.org/pub/journals/latex2e
\end_layout
@ -2193,7 +2196,7 @@ WWW: available from the Kluwer Academic Publishers site
\begin_inset Flex URL
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
http://www.wkap.nl/kaphtml.htm/STYLEFILES
\end_layout
@ -2217,7 +2220,7 @@ Astrophysics and Space Science, Solar Physics
\begin_inset Flex URL
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
http://www.wkap.nl/jrnllist.htm/JRNLHOME
\end_layout
@ -2462,12 +2465,14 @@ Lecture Notes in Computer Science
.
LaTeX documents are available from Springer's ftp site on the following
URL:
\newline
\begin_inset Newline newline
\end_inset
\begin_inset Flex URL
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
ftp://trick.ntp.springer.de/pub/tex/latex/llncs/latex2e
\end_layout
@ -2665,7 +2670,7 @@ WWW:
\begin_inset Flex URL
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
http://public.lanl.gov/kmh/spie/
\end_layout
@ -2686,7 +2691,7 @@ spie.cls
\begin_inset Flex URL
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
http://spie.org/app/Publications/index.cfm?fuseaction=authinfo&type=proceedings
\end_layout
@ -2768,7 +2773,7 @@ Notes: REVTeX 4 is a class used for submitting manuscripts to journals including
\begin_inset Flex URL
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
http://publish.aps.org/revtex4/
\end_layout
@ -2879,7 +2884,7 @@ WWW:
\begin_inset Flex URL
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
http://www.springeronline.com
\end_layout
@ -2954,7 +2959,7 @@ WWW:
\begin_inset Flex URL
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
http://www.springeronline.com
\end_layout
@ -3007,7 +3012,7 @@ WWW:
\begin_inset Flex URL
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
http://www.springeronline.com
\end_layout
@ -3075,7 +3080,7 @@ WWW:
\begin_inset Flex URL
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
http://www.tug.org
\end_layout
@ -3116,7 +3121,7 @@ WWW:
\begin_inset Flex URL
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
http://www.photogrammetry.ethz.ch/tarasp_workshop/isprs.cls
\end_layout
@ -3460,7 +3465,7 @@ arg "graphicsdriver"
\begin_inset Foot
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
Here, a value of
\begin_inset Quotes eld
\end_inset
@ -4111,7 +4116,7 @@ jurabib
\begin_inset Flex URL
status collapsed
\begin_layout PlainLayout
\begin_layout Plain Layout
http://www.jurabib.org
\end_layout
@ -4256,6 +4261,40 @@ nomencl
is needed by LyX to produce a nomenclature.
\end_layout
\begin_layout Subsection
pdfpages
\end_layout
\begin_layout Description
Found:
\begin_inset Info
type "package"
arg "pdfpages"
\end_inset
\end_layout
\begin_layout Description
CTAN:
\family typewriter
macros/latex/contrib/pdfpages
\end_layout
\begin_layout Description
Notes: The package
\family typewriter
pdfpages
\family default
is used by LyX to include multi-page PDF files via
\family sans
Insert\SpecialChar \menuseparator
File\SpecialChar \menuseparator
External Material
\family default
.
\end_layout
\begin_layout Subsection
prettyref
\end_layout
@ -4410,7 +4449,10 @@ Notes: The package
\family sans
subfig
\family default
is used by LyX to produce subfloats (i.\InsetSpace \thinspace{}
is used by LyX to produce subfloats (i.
\begin_inset Space \thinspace{}
\end_inset
e., subfigures, subtables, etc.).
Subfloats are floats that are embedded inside other floats and that can
have individual subcaptions.

View File

@ -244,6 +244,56 @@ Template LilyPond
FormatEnd
TemplateEnd
Template PDFPages
GuiName "PDF pages: $$AbsOrRelPathParent$$Basename"
HelpText
Includes PDF documents, using the 'pdfpages' package.
To include multiple pages, use the "pages"-option,
which must be inserted to "Options" (Format "PDFLaTeX").
Examples:
* pages={x-y} (for a range of pages)
* pages={x,y,z} (for specific pages)
* pages=- (to include all pages)
Read the documentation of the pdfpages package
for further options and details.
HelpTextEnd
InputFormat pdf
FileFilter "*.pdf"
Transform Rotate
Transform Resize
Transform Extra
Format LaTeX
TransformOption Rotate RotationLatexOption
TransformOption Resize ResizeLatexOption
TransformOption Extra ExtraOption
Option Arg "[$$Extra,$$Rotate,$$Resize]"
Product "\\includepdf$$Arg{$$AbsOrRelPathMaster$$Basename}"
UpdateFormat pdf
UpdateResult "$$AbsPath$$Basename.pdf"
Requirement "pdfpages"
ReferencedFile pdflatex "$$AbsPath$$Basename.pdf"
FormatEnd
Format PDFLaTeX
TransformOption Rotate RotationLatexOption
TransformOption Resize ResizeLatexOption
TransformOption Extra ExtraOption
Option Arg "[$$Extra,$$Rotate,$$Resize]"
Product "\\includepdf$$Arg{$$AbsOrRelPathMaster$$Basename}"
UpdateFormat pdf
UpdateResult "$$AbsPath$$Basename.pdf"
Requirement "pdfpages"
ReferencedFile pdflatex "$$AbsPath$$Basename.pdf"
FormatEnd
Format Ascii
Product "[PDFPages: $$FName]"
FormatEnd
Format DocBook
Product "[PDFPages: $$FName]"
FormatEnd
TemplateEnd
Template Date
GuiName "Date"

View File

@ -80,7 +80,7 @@ format_relation = [("0_06", [200], minor_versions("0.6" , 4)),
("1_3", [221], minor_versions("1.3" , 7)),
("1_4", range(222,246), minor_versions("1.4" , 5)),
("1_5", range(246,277), minor_versions("1.5" , 2)),
("1_6", range(277,326), minor_versions("1.6" , 0))]
("1_6", range(277,327), minor_versions("1.6" , 0))]
def formats_list():

View File

@ -45,6 +45,29 @@ def add_to_preamble(document, text):
document.preamble.extend(text)
# Convert a LyX length into a LaTeX length
def convert_len(len):
units = {"text%":"\\backslash\ntextwidth", "col%":"\\backslash\ncolumnwidth",
"page%":"\\backslash\npagewidth", "line%":"\\backslash\nlinewidth",
"theight%":"\\backslash\ntextheight", "pheight%":"\\backslash\npageheight"}
# Convert LyX units to LaTeX units
for unit in units.keys():
if len.find(unit) != -1:
len = '%f' % (len2value(len) / 100)
len = len.strip('0') + units[unit]
break
return len
# Return the value of len without the unit in numerical form.
def len2value(len):
result = re.search('([+-]?[0-9.]+)', len)
if result:
return float(result.group(1))
# No number means 1.0
return 1.0
####################################################################
def get_option(document, m, option, default):
@ -1730,7 +1753,7 @@ def revert_linebreaks(document):
def convert_japanese_plain(document):
"Set language japanese-plain to japanese"
' Set language japanese-plain to japanese '
i = 0
if document.language == "japanese-plain":
document.language = "japanese"
@ -1746,6 +1769,76 @@ def convert_japanese_plain(document):
j = j + 1
def revert_pdfpages(document):
' Revert pdfpages external inset to ERT '
i = 0
while 1:
i = find_token(document.body, "\\begin_inset External", i)
if i == -1:
return
j = find_end_of_inset(document.body, i)
if j == -1:
document.warning("Malformed lyx document: Missing '\\end_inset'.")
i = i + 1
continue
if get_value(document.body, 'template', i, j) == "PDFPages":
filename = get_value(document.body, 'filename', i, j)
extra = ''
r = re.compile(r'\textra PDFLaTeX \"(.*)\"$')
for k in range(i, j):
m = r.match(document.body[k])
if m:
extra = m.group(1)
angle = get_value(document.body, 'rotateAngle', i, j)
width = get_value(document.body, 'width', i, j)
height = get_value(document.body, 'height', i, j)
scale = get_value(document.body, 'scale', i, j)
keepAspectRatio = find_token(document.body, "\tkeepAspectRatio", i, j)
options = extra
if angle != '':
if options != '':
options += ",angle=" + angle
else:
options += "angle=" + angle
if width != '':
if options != '':
options += ",width=" + convert_len(width)
else:
options += "width=" + convert_len(width)
if height != '':
if options != '':
options += ",height=" + convert_len(height)
else:
options += "height=" + convert_len(height)
if scale != '':
if options != '':
options += ",scale=" + scale
else:
options += "scale=" + scale
if keepAspectRatio != '':
if options != '':
options += ",keepaspectratio"
else:
options += "keepaspectratio"
if options != '':
options = '[' + options + ']'
del document.body[i+1:j+1]
document.body[i:i+1] = ['\\begin_inset ERT',
'status collapsed',
'',
'\\begin_layout Standard',
'',
'\\backslash',
'includepdf' + options + '{' + filename + '}',
'\\end_layout',
'',
'\\end_inset']
add_to_preamble(document, ['\\usepackage{pdfpages}\n'])
i = i + 1
continue
i = i + 1
##
# Conversion hub
#
@ -1800,9 +1893,11 @@ convert = [[277, [fix_wrong_tables]],
[323, [convert_pagebreaks]],
[324, [convert_linebreaks]],
[325, [convert_japanese_plain]],
[326, []]
]
revert = [[324, []],
revert = [[325, [revert_pdfpages]],
[324, []],
[323, [revert_linebreaks]],
[322, [revert_pagebreaks]],
[321, [revert_local_layout]],

View File

@ -117,7 +117,7 @@ namespace os = support::os;
namespace {
int const LYX_FORMAT = 325;
int const LYX_FORMAT = 326;
typedef map<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;

View File

@ -450,7 +450,8 @@ char const * simplefeatures[] = {
"ifthen",
"amsthm",
"listings",
"bm"
"bm",
"pdfpages"
};
int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);