mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 21:40:19 +00:00
Use generic paper size names rather than LaTeXisms such as "letterpaper"
This allows to support classes that don't use the Xpaper wording. Add support for KOMA font (keyval) syntax on top of that. Also support class-specific font and paper sizes in tex2lyx. File and layout format change.
This commit is contained in:
parent
1386a3d8fd
commit
0b7305024a
@ -7,6 +7,10 @@ changes happened in particular if possible. A good example would be
|
||||
|
||||
-----------------------
|
||||
|
||||
2019-08-07 Jürgen Spitzmüller <spitz@lyx.org>
|
||||
* Format incremented to 587: Use more generic paper names as LyX names
|
||||
(rather than LaTeXisms; e.g., "a4" rather than "a4paper").
|
||||
|
||||
2019-08-07 Jürgen Spitzmüller <spitz@lyx.org>
|
||||
* Format incremented to 586: Allow for duplicate keys in qualified citation lists
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX 2.4 created this file. For more info see https://www.lyx.org/
|
||||
\lyxformat 585
|
||||
\lyxformat 587
|
||||
\begin_document
|
||||
\begin_header
|
||||
\save_transient_properties true
|
||||
@ -10531,10 +10531,8 @@ status collapsed
|
||||
\emph on
|
||||
custom
|
||||
\emph default
|
||||
, letterpaper, legalpaper, executivepaper, a0paper, a1paper, a2paper, a3paper,
|
||||
a4paper, a5paper, a6paper, b0paper, b1paper, b2paper, b3paper, b4paper,
|
||||
b5paper, b6paper, c0paper, c1paper, c2paper, c3paper, c4paper, c5paper,
|
||||
c6paper, b0j, b1j, b2j, b3j, b4j, b5j, b6j
|
||||
, letter, legal, executive, a0, a1, a2, a3, a4, a5, a6, b0, b1, b2, b3,
|
||||
b4, b5, b6, c0, c1, c2, c3, c4, c5, c6, b0j, b1j, b2j, b3j, b4j, b5j, b6j
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
@ -11629,7 +11627,7 @@ g.: PUBLIC
|
||||
|
||||
\begin_layout Description
|
||||
|
||||
\change_inserted -712698321 1565105413
|
||||
\change_inserted -712698321 1565180598
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
@ -11648,40 +11646,38 @@ status collapsed
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted -712698321 1565105399
|
||||
string="letterpaper|\SpecialChar allowbreak
|
||||
legalpaper|\SpecialChar allowbreak
|
||||
executivepaper|\SpecialChar allowbreak
|
||||
a0paper|\SpecialChar allowbreak
|
||||
a1paper|\SpecialChar allowbreak
|
||||
a2paper|\SpecialChar allowbreak
|
||||
a3paper|\SpecialChar allowbreak
|
||||
a4
|
||||
paper|\SpecialChar allowbreak
|
||||
a5paper|\SpecialChar allowbreak
|
||||
a6paper|\SpecialChar allowbreak
|
||||
b0paper|\SpecialChar allowbreak
|
||||
b1paper|\SpecialChar allowbreak
|
||||
b2paper|\SpecialChar allowbreak
|
||||
b3paper|\SpecialChar allowbreak
|
||||
b4paper|\SpecialChar allowbreak
|
||||
b5paper|\SpecialChar allowbreak
|
||||
b6paper|\SpecialChar allowbreak
|
||||
c0
|
||||
paper|\SpecialChar allowbreak
|
||||
c1paper|\SpecialChar allowbreak
|
||||
c2paper|\SpecialChar allowbreak
|
||||
c3paper|\SpecialChar allowbreak
|
||||
c4paper|\SpecialChar allowbreak
|
||||
c5paper|\SpecialChar allowbreak
|
||||
c6paper|\SpecialChar allowbreak
|
||||
string="letter|\SpecialChar allowbreak
|
||||
legal|\SpecialChar allowbreak
|
||||
executive|\SpecialChar allowbreak
|
||||
a0|\SpecialChar allowbreak
|
||||
a1|\SpecialChar allowbreak
|
||||
a2|\SpecialChar allowbreak
|
||||
a3|\SpecialChar allowbreak
|
||||
a4|\SpecialChar allowbreak
|
||||
a5|\SpecialChar allowbreak
|
||||
a6|\SpecialChar allowbreak
|
||||
b0|\SpecialChar allowbreak
|
||||
b1|\SpecialChar allowbreak
|
||||
b2|\SpecialChar allowbreak
|
||||
b3|\SpecialChar allowbreak
|
||||
b4|\SpecialChar allowbreak
|
||||
b5|\SpecialChar allowbreak
|
||||
b6|\SpecialChar allowbreak
|
||||
c0|\SpecialChar allowbreak
|
||||
c1|\SpecialChar allowbreak
|
||||
c
|
||||
2|\SpecialChar allowbreak
|
||||
c3|\SpecialChar allowbreak
|
||||
c4|\SpecialChar allowbreak
|
||||
c5|\SpecialChar allowbreak
|
||||
c6|\SpecialChar allowbreak
|
||||
b0j|\SpecialChar allowbreak
|
||||
b1j|\SpecialChar allowbreak
|
||||
b2j|\SpecialChar allowbreak
|
||||
b3j|\SpecialChar allowbreak
|
||||
b4j|\SpecialChar allowbreak
|
||||
b5j|\SpecialChar allowbreak
|
||||
b6
|
||||
j"
|
||||
b6j"
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
@ -11709,6 +11705,61 @@ status collapsed
|
||||
.
|
||||
Currently, only the listed sizes are supported.
|
||||
Other sizes might be entered as custom class option.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
||||
\change_inserted -712698321 1565180623
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted -712698321 1565180605
|
||||
PageSizeFormat
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
[
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted -712698321 1565180601
|
||||
string
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
] The format for the page size option.
|
||||
Default:
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted -712698321 1565180618
|
||||
$$spaper
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
.
|
||||
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted -712698321 1565180601
|
||||
$$s
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
is a placeholder for the paper size.
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX 2.4 created this file. For more info see https://www.lyx.org/
|
||||
\lyxformat 585
|
||||
\lyxformat 587
|
||||
\begin_document
|
||||
\begin_header
|
||||
\save_transient_properties true
|
||||
@ -8750,10 +8750,8 @@ status collapsed
|
||||
\emph on
|
||||
custom
|
||||
\emph default
|
||||
, letterpaper, legalpaper, executivepaper, a0paper, a1paper, a2paper, a3paper,
|
||||
a4paper, a5paper, a6paper, b0paper, b1paper, b2paper, b3paper, b4paper,
|
||||
b5paper, b6paper, c0paper, c1paper, c2paper, c3paper, c4paper, c5paper,
|
||||
c6paper, b0j, b1j, b2j, b3j, b4j, b5j, b6j
|
||||
, letter, legal, executive, a0, a1, a2, a3, a4, a5, a6, b0, b1, b2, b3,
|
||||
b4, b5, b6, c0, c1, c2, c3, c4, c5, c6, b0j, b1j, b2j, b3j, b4j, b5j, b6j
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
@ -9795,40 +9793,38 @@ PageSize
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
string="letterpaper|\SpecialChar allowbreak
|
||||
legalpaper|\SpecialChar allowbreak
|
||||
executivepaper|\SpecialChar allowbreak
|
||||
a0paper|\SpecialChar allowbreak
|
||||
a1paper|\SpecialChar allowbreak
|
||||
a2paper|\SpecialChar allowbreak
|
||||
a3paper|\SpecialChar allowbreak
|
||||
a4
|
||||
paper|\SpecialChar allowbreak
|
||||
a5paper|\SpecialChar allowbreak
|
||||
a6paper|\SpecialChar allowbreak
|
||||
b0paper|\SpecialChar allowbreak
|
||||
b1paper|\SpecialChar allowbreak
|
||||
b2paper|\SpecialChar allowbreak
|
||||
b3paper|\SpecialChar allowbreak
|
||||
b4paper|\SpecialChar allowbreak
|
||||
b5paper|\SpecialChar allowbreak
|
||||
b6paper|\SpecialChar allowbreak
|
||||
c0
|
||||
paper|\SpecialChar allowbreak
|
||||
c1paper|\SpecialChar allowbreak
|
||||
c2paper|\SpecialChar allowbreak
|
||||
c3paper|\SpecialChar allowbreak
|
||||
c4paper|\SpecialChar allowbreak
|
||||
c5paper|\SpecialChar allowbreak
|
||||
c6paper|\SpecialChar allowbreak
|
||||
string="letter|\SpecialChar allowbreak
|
||||
legal|\SpecialChar allowbreak
|
||||
executive|\SpecialChar allowbreak
|
||||
a0|\SpecialChar allowbreak
|
||||
a1|\SpecialChar allowbreak
|
||||
a2|\SpecialChar allowbreak
|
||||
a3|\SpecialChar allowbreak
|
||||
a4|\SpecialChar allowbreak
|
||||
a5|\SpecialChar allowbreak
|
||||
a6|\SpecialChar allowbreak
|
||||
b0|\SpecialChar allowbreak
|
||||
b1|\SpecialChar allowbreak
|
||||
b2|\SpecialChar allowbreak
|
||||
b3|\SpecialChar allowbreak
|
||||
b4|\SpecialChar allowbreak
|
||||
b5|\SpecialChar allowbreak
|
||||
b6|\SpecialChar allowbreak
|
||||
c0|\SpecialChar allowbreak
|
||||
c1|\SpecialChar allowbreak
|
||||
c
|
||||
2|\SpecialChar allowbreak
|
||||
c3|\SpecialChar allowbreak
|
||||
c4|\SpecialChar allowbreak
|
||||
c5|\SpecialChar allowbreak
|
||||
c6|\SpecialChar allowbreak
|
||||
b0j|\SpecialChar allowbreak
|
||||
b1j|\SpecialChar allowbreak
|
||||
b2j|\SpecialChar allowbreak
|
||||
b3j|\SpecialChar allowbreak
|
||||
b4j|\SpecialChar allowbreak
|
||||
b5j|\SpecialChar allowbreak
|
||||
b6
|
||||
j"
|
||||
b6j"
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
@ -9861,6 +9857,51 @@ status collapsed
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
PageSizeFormat
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
[
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
string
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
] Das Format der Seitengrößen-Option.
|
||||
Voreinstellung:
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
$$spaper
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
.
|
||||
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
$$s
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
ist ein Platzhalter für die Papiergröße.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
PageStyle
|
||||
\end_layout
|
||||
|
@ -14,7 +14,7 @@ SecNumDepth 1
|
||||
TocDepth 1
|
||||
DefaultStyle Standard
|
||||
PageStyle Headings
|
||||
PageSize letterpaper
|
||||
PageSize letter
|
||||
Provides makeidx 1
|
||||
Provides framed 1
|
||||
Provides subscript 1
|
||||
@ -28,7 +28,7 @@ Provides SetSpace 1
|
||||
|
||||
ClassOptions
|
||||
FontSize 9|10|11|12|14|17
|
||||
PageSize a3paper|a4paper|a5paper|a6paper|b3paper|b4paper|b5paper|b6paper|executivepaper|legalpaper|letterpaper
|
||||
PageSize a3|a4|a5|a6|b3|b4|b5|b6|executive|legal|letter
|
||||
PageStyle empty|plain|headings|myheadings|ruled|Ruled|companion
|
||||
Other oldfontcommands
|
||||
End
|
||||
|
@ -12,13 +12,14 @@ Format 78
|
||||
SecNumDepth 2
|
||||
TocDepth 2
|
||||
DefaultStyle Standard
|
||||
PageSize a4paper
|
||||
PageSize a4
|
||||
Provides subscript 1
|
||||
|
||||
ClassOptions
|
||||
FontSize 9|10|11|12|13|14|15|16|17|18|19|20
|
||||
FontSizeFormat fontsize=$$s
|
||||
PageSize a0paper|a1paper|a2paper|a3paper|a4paper|a5paper|a6paper|b0paper|b1paper|b2paper|b3paper|b4paper|b5paper|b6paper|c0paper|c1paper|c2paper|c3paper|c4paper|c5paper|c6paper|executivepaper|legalpaper|letterpaper
|
||||
PageSize a0|a1|a2|a3|a4|a5|a6|b0|b1|b2|b3|b4|b5|b6|c0|c1|c2|c3|c4|c5|c6|executive|legal|letter
|
||||
PageSizeFormat paper=$$s
|
||||
End
|
||||
|
||||
Style Standard
|
||||
|
@ -3357,6 +3357,38 @@ def revert_dupqualicites(document):
|
||||
res += "{" + kk + "}"
|
||||
document.body[i:j+1] = put_cmd_in_ert([res])
|
||||
|
||||
|
||||
def convert_pagesizenames(document):
|
||||
" Convert LyX page sizes names "
|
||||
|
||||
i = find_token(document.header, "\\papersize", 0)
|
||||
if i == -1:
|
||||
document.warning("Malformed LyX document! Missing \\papersize header.")
|
||||
return
|
||||
oldnames = ["letterpaper", "legalpaper", "executivepaper", \
|
||||
"a0paper", "a1paper", "a2paper", "a3paper", "a4paper", "a5paper", "a6paper", \
|
||||
"b0paper", "b1paper", "b2paper", "b3paper", "b4paper", "b5paper", "b6paper", \
|
||||
"c0paper", "c1paper", "c2paper", "c3paper", "c4paper", "c5paper", "c6paper"]
|
||||
val = get_value(document.header, "\\papersize", i)
|
||||
if val in oldnames:
|
||||
newval = val.replace("paper", "")
|
||||
document.header[i] = "\\papersize " + newval
|
||||
|
||||
def revert_pagesizenames(document):
|
||||
" Convert LyX page sizes names "
|
||||
|
||||
i = find_token(document.header, "\\papersize", 0)
|
||||
if i == -1:
|
||||
document.warning("Malformed LyX document! Missing \\papersize header.")
|
||||
return
|
||||
newnames = ["letter", "legal", "executive", \
|
||||
"a0", "a1", "a2", "a3", "a4", "a5", "a6", \
|
||||
"b0", "b1", "b2", "b3", "b4", "b5", "b6", \
|
||||
"c0", "c1", "c2", "c3", "c4", "c5", "c6"]
|
||||
val = get_value(document.header, "\\papersize", i)
|
||||
if val in newnames:
|
||||
newval = val + "paper"
|
||||
document.header[i] = "\\papersize " + newval
|
||||
|
||||
|
||||
##
|
||||
@ -3406,10 +3438,12 @@ convert = [
|
||||
[583, [convert_ChivoFont,convert_Semibolds,convert_NotoRegulars,convert_CrimsonProFont]],
|
||||
[584, []],
|
||||
[585, [convert_pagesizes]],
|
||||
[586, []]
|
||||
[586, []],
|
||||
[587, [convert_pagesizenames]]
|
||||
]
|
||||
|
||||
revert = [[585, [revert_dupqualicites]],
|
||||
revert = [[586, [revert_pagesizenames]],
|
||||
[585, [revert_dupqualicites]],
|
||||
[584, [revert_pagesizes,revert_komafontsizes]],
|
||||
[583, [revert_vcsinfo_rev_abbrev]],
|
||||
[582, [revert_ChivoFont,revert_CrimsonProFont]],
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This script will update a .layout file to current format
|
||||
|
||||
# The latest layout format is also defined in src/TextClass.cpp
|
||||
currentFormat = 78
|
||||
currentFormat = 79
|
||||
|
||||
|
||||
# Incremented to format 4, 6 April 2007, lasgouttes
|
||||
@ -262,6 +262,9 @@ currentFormat = 78
|
||||
# Incremented to format 78, 6 August 2019 by spitz
|
||||
# New textclass tag FontsizeFormat
|
||||
|
||||
# Incremented to format 79, 7 August 2019 by spitz
|
||||
# New textclass tag PagesizeFormat
|
||||
|
||||
# Do not forget to document format change in Customization
|
||||
# Manual (section "Declaring a new text class").
|
||||
|
||||
|
@ -79,12 +79,20 @@ static char const * const string_quotes_style[] = {
|
||||
|
||||
|
||||
static char const * const string_papersize[] = {
|
||||
"default", "custom", "letter", "legal", "executive",
|
||||
"a0", "a1", "a2", "a3", "a4", "a5", "a6",
|
||||
"b0", "b1", "b2", "b3", "b4", "b5", "b6",
|
||||
"c0", "c1", "c2", "c3", "c4", "c5", "c6",
|
||||
"b0j", "b1j", "b2j", "b3j", "b4j", "b5j", "b6j", ""
|
||||
};
|
||||
|
||||
|
||||
static char const * const string_papersize_geometry[] = {
|
||||
"default", "custom", "letterpaper", "legalpaper", "executivepaper",
|
||||
"a0paper", "a1paper", "a2paper", "a3paper", "a4paper", "a5paper",
|
||||
"a6paper", "b0paper", "b1paper", "b2paper", "b3paper", "b4paper",
|
||||
"b5paper", "b6paper", "c0paper", "c1paper", "c2paper", "c3paper",
|
||||
"c4paper", "c5paper", "c6paper", "b0j", "b1j", "b2j", "b3j", "b4j", "b5j",
|
||||
"b6j", ""
|
||||
"a0paper", "a1paper", "a2paper", "a3paper", "a4paper", "a5paper", "a6paper",
|
||||
"b0paper", "b1paper", "b2paper", "b3paper", "b4paper", "b5paper", "b6paper",
|
||||
"c0paper", "c1paper", "c2paper", "c3paper", "c4paper", "c5paper", "c6paper",
|
||||
"b0j", "b1j", "b2j", "b3j", "b4j", "b5j", "b6j", ""
|
||||
};
|
||||
|
||||
|
||||
@ -1628,7 +1636,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
|
||||
|
||||
if ((!use_geometry || features.isProvided("geometry-light"))
|
||||
&& class_supported_papersize)
|
||||
clsoptions << string_papersize[papersize] << ",";
|
||||
clsoptions << subst(tclass.pagesizeformat(), "$$s", string_papersize[papersize]) << ",";
|
||||
|
||||
// if needed
|
||||
if (sides != tclass.sides()) {
|
||||
@ -1849,7 +1857,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
|
||||
case PAPER_JISB4:
|
||||
case PAPER_JISB5:
|
||||
case PAPER_JISB6:
|
||||
ods << "," << from_ascii(string_papersize[papersize]);
|
||||
ods << "," << from_ascii(string_papersize_geometry[papersize]);
|
||||
break;
|
||||
case PAPER_DEFAULT:
|
||||
break;
|
||||
|
@ -62,7 +62,7 @@ namespace lyx {
|
||||
// You should also run the development/tools/updatelayouts.py script,
|
||||
// to update the format of all of our layout files.
|
||||
//
|
||||
int const LAYOUT_FORMAT = 78; // spitz: FontsizeFormat
|
||||
int const LAYOUT_FORMAT = 79; // spitz: PagesizeFormat
|
||||
|
||||
|
||||
// Layout format for the current lyx file format. Controls which format is
|
||||
@ -150,11 +150,11 @@ docstring const TextClass::plain_layout_ = from_ascii(N_("Plain Layout"));
|
||||
TextClass::TextClass()
|
||||
: loaded_(false), tex_class_avail_(false),
|
||||
opt_enginetype_("authoryear|numerical"), opt_fontsize_("10|11|12"),
|
||||
opt_pagesize_("default|a4paper|a5paper|b5paper|letterpaper|legalpaper|executivepaper"),
|
||||
opt_pagesize_("default|a4|a5|b5|letter|legal|executive"),
|
||||
opt_pagestyle_("empty|plain|headings|fancy"), fontsize_format_("$$spt"), pagesize_("default"),
|
||||
pagestyle_("default"), tablestyle_("default"), columns_(1), sides_(OneSide), secnumdepth_(3),
|
||||
tocdepth_(3), outputType_(LATEX), outputFormat_("latex"),
|
||||
has_output_format_(false), defaultfont_(sane_font),
|
||||
pagesize_format_("$$spaper"), pagestyle_("default"), tablestyle_("default"),
|
||||
columns_(1), sides_(OneSide), secnumdepth_(3), tocdepth_(3), outputType_(LATEX),
|
||||
outputFormat_("latex"), has_output_format_(false), defaultfont_(sane_font),
|
||||
titletype_(TITLE_COMMAND_AFTER), titlename_("maketitle"),
|
||||
min_toclevel_(0), max_toclevel_(0), maxcitenames_(2),
|
||||
cite_full_author_list_(true), bibintoc_(false)
|
||||
@ -1006,6 +1006,7 @@ void TextClass::readClassOptions(Lexer & lexrc)
|
||||
CO_FONTSIZE = 1,
|
||||
CO_FONTSIZE_FORMAT,
|
||||
CO_PAGESIZE,
|
||||
CO_PAGESIZE_FORMAT,
|
||||
CO_PAGESTYLE,
|
||||
CO_OTHER,
|
||||
CO_HEADER,
|
||||
@ -1019,6 +1020,7 @@ void TextClass::readClassOptions(Lexer & lexrc)
|
||||
{"header", CO_HEADER },
|
||||
{"other", CO_OTHER },
|
||||
{"pagesize", CO_PAGESIZE },
|
||||
{"pagesizeformat", CO_PAGESIZE_FORMAT },
|
||||
{"pagestyle", CO_PAGESTYLE }
|
||||
};
|
||||
|
||||
@ -1046,6 +1048,10 @@ void TextClass::readClassOptions(Lexer & lexrc)
|
||||
lexrc.next();
|
||||
opt_pagesize_ = rtrim(lexrc.getString());
|
||||
break;
|
||||
case CO_PAGESIZE_FORMAT:
|
||||
lexrc.next();
|
||||
pagesize_format_ = rtrim(lexrc.getString());
|
||||
break;
|
||||
case CO_PAGESTYLE:
|
||||
lexrc.next();
|
||||
opt_pagestyle_ = rtrim(lexrc.getString());
|
||||
|
@ -280,6 +280,8 @@ protected:
|
||||
std::string fontsize_format_;
|
||||
/// Default page size
|
||||
std::string pagesize_;
|
||||
/// Format of the papersize option
|
||||
std::string pagesize_format_;
|
||||
///
|
||||
std::string pagestyle_;
|
||||
///
|
||||
@ -467,6 +469,8 @@ public:
|
||||
///
|
||||
std::string const & pagesize() const { return pagesize_; }
|
||||
///
|
||||
std::string const & pagesizeformat() const { return pagesize_format_; }
|
||||
///
|
||||
std::string const & pagestyle() const { return pagestyle_; }
|
||||
///
|
||||
std::string const & tablestyle() const { return tablestyle_; }
|
||||
|
@ -158,15 +158,12 @@ const char * const known_typewriter_font_packages[] = { "beramono", "cmtl", "cmt
|
||||
|
||||
const char * const known_math_font_packages[] = { "eulervm", "newtxmath", 0};
|
||||
|
||||
const char * const known_paper_sizes[] = { "a0paper", "b0paper", "c0paper",
|
||||
const char * const known_latex_paper_sizes[] = { "a0paper", "b0paper", "c0paper",
|
||||
"a1paper", "b1paper", "c1paper", "a2paper", "b2paper", "c2paper", "a3paper",
|
||||
"b3paper", "c3paper", "a4paper", "b4paper", "c4paper", "a5paper", "b5paper",
|
||||
"c5paper", "a6paper", "b6paper", "c6paper", "executivepaper", "legalpaper",
|
||||
"letterpaper", "b0j", "b1j", "b2j", "b3j", "b4j", "b5j", "b6j", 0};
|
||||
|
||||
const char * const known_class_paper_sizes[] = { "a4paper", "a5paper",
|
||||
"executivepaper", "legalpaper", "letterpaper", 0};
|
||||
|
||||
const char * const known_paper_margins[] = { "lmargin", "tmargin", "rmargin",
|
||||
"bmargin", "headheight", "headsep", "footskip", "columnsep", 0};
|
||||
|
||||
@ -709,13 +706,18 @@ void Preamble::handle_geometry(vector<string> & options)
|
||||
options.erase(it);
|
||||
}
|
||||
// paper size
|
||||
// keyval version: "paper=letter"
|
||||
// keyval version: "paper=letter" or "paper=letterpaper"
|
||||
string paper = process_keyval_opt(options, "paper");
|
||||
if (!paper.empty())
|
||||
h_papersize = paper + "paper";
|
||||
if (suffixIs(paper, "paper"))
|
||||
paper = subst(paper, "paper", "");
|
||||
// alternative version: "letterpaper"
|
||||
handle_opt(options, known_paper_sizes, h_papersize);
|
||||
delete_opt(options, known_paper_sizes);
|
||||
handle_opt(options, known_latex_paper_sizes, paper);
|
||||
if (suffixIs(paper, "paper"))
|
||||
paper = subst(paper, "paper", "");
|
||||
delete_opt(options, known_latex_paper_sizes);
|
||||
if (!paper.empty())
|
||||
h_papersize = paper;
|
||||
// page margins
|
||||
char const * const * margin = known_paper_margins;
|
||||
for (; *margin; ++margin) {
|
||||
@ -2543,12 +2545,41 @@ void Preamble::parse(Parser & p, string const & forceclass,
|
||||
if (t.cs() == "documentclass") {
|
||||
vector<string>::iterator it;
|
||||
vector<string> opts = split_options(p.getArg('[', ']'));
|
||||
// FIXME This does not work for classes that have a
|
||||
// different name in LyX than in LaTeX
|
||||
h_textclass = p.getArg('{', '}');
|
||||
p.skip_spaces();
|
||||
// Force textclass if the user wanted it
|
||||
if (!forceclass.empty())
|
||||
h_textclass = forceclass;
|
||||
tc.setName(h_textclass);
|
||||
if (!LayoutFileList::get().haveClass(h_textclass) || !tc.load()) {
|
||||
cerr << "Error: Could not read layout file for textclass \"" << h_textclass << "\"." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Font sizes.
|
||||
// Try those who are (most likely) known to all packages first
|
||||
handle_opt(opts, known_fontsizes, h_paperfontsize);
|
||||
delete_opt(opts, known_fontsizes);
|
||||
// delete "pt" at the end
|
||||
string::size_type i = h_paperfontsize.find("pt");
|
||||
if (i != string::npos)
|
||||
h_paperfontsize.erase(i);
|
||||
// Now those known specifically to the class
|
||||
string fsize;
|
||||
vector<string> class_fsizes = getVectorFromString(tc.opt_fontsize(), "|");
|
||||
string const fsize_format = tc.fontsizeformat();
|
||||
for (auto const fsize : class_fsizes) {
|
||||
string latexsize = subst(fsize_format, "$$s", fsize);
|
||||
vector<string>::iterator it = find(opts.begin(), opts.end(), latexsize);
|
||||
if (it != opts.end()) {
|
||||
h_paperfontsize = fsize;
|
||||
opts.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// The documentclass options are always parsed before the options
|
||||
// of the babel call so that a language cannot overwrite the babel
|
||||
// options.
|
||||
@ -2601,16 +2632,33 @@ void Preamble::parse(Parser & p, string const & forceclass,
|
||||
opts.erase(it);
|
||||
}
|
||||
// paper sizes
|
||||
// some size options are known to any document classes, other sizes
|
||||
// some size options are known by the document class, other sizes
|
||||
// are handled by the \geometry command of the geometry package
|
||||
handle_opt(opts, known_class_paper_sizes, h_papersize);
|
||||
delete_opt(opts, known_class_paper_sizes);
|
||||
string paper;
|
||||
vector<string> class_psizes = getVectorFromString(tc.opt_pagesize(), "|");
|
||||
string const psize_format = tc.pagesizeformat();
|
||||
for (auto const psize : class_psizes) {
|
||||
string latexsize = subst(psize_format, "$$s", psize);
|
||||
vector<string>::iterator it = find(opts.begin(), opts.end(), latexsize);
|
||||
if (it != opts.end()) {
|
||||
h_papersize = psize;
|
||||
opts.erase(it);
|
||||
break;
|
||||
}
|
||||
if (psize_format == "$$spaper")
|
||||
continue;
|
||||
// Also try with the default format since this is understood by
|
||||
// most classes
|
||||
latexsize = psize + "paper";
|
||||
it = find(opts.begin(), opts.end(), latexsize);
|
||||
if (it != opts.end()) {
|
||||
h_papersize = psize;
|
||||
opts.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// the remaining options
|
||||
h_options = join(opts, ",");
|
||||
// FIXME This does not work for classes that have a
|
||||
// different name in LyX than in LaTeX
|
||||
h_textclass = p.getArg('{', '}');
|
||||
p.skip_spaces();
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -2935,14 +2983,6 @@ void Preamble::parse(Parser & p, string const & forceclass,
|
||||
// remove the whitespace
|
||||
p.skip_spaces();
|
||||
|
||||
// Force textclass if the user wanted it
|
||||
if (!forceclass.empty())
|
||||
h_textclass = forceclass;
|
||||
tc.setName(h_textclass);
|
||||
if (!LayoutFileList::get().haveClass(h_textclass) || !tc.load()) {
|
||||
cerr << "Error: Could not read layout file for textclass \"" << h_textclass << "\"." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (h_papersides.empty()) {
|
||||
ostringstream ss;
|
||||
ss << tc.sides();
|
||||
|
@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
|
||||
|
||||
// Do not remove the comment below, so we get merge conflict in
|
||||
// independent branches. Instead add your own.
|
||||
#define LYX_FORMAT_LYX 586 // spitz: allow duplicate keys in qualified citation lists
|
||||
#define LYX_FORMAT_TEX2LYX 586
|
||||
#define LYX_FORMAT_LYX 587 // spitz: generic paper size names
|
||||
#define LYX_FORMAT_TEX2LYX 587
|
||||
|
||||
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
||||
#ifndef _MSC_VER
|
||||
|
Loading…
Reference in New Issue
Block a user