moderncv.layout: update some styles and add new ones

- support for at least modernCV 1.5 (layout will still work with moderncv 1.3 as before)
- fileformat change
This commit is contained in:
Uwe Stöhr 2015-10-28 02:27:32 +01:00
parent 1eaa2366bf
commit 2c1851e2ec
22 changed files with 353 additions and 42 deletions

View File

@ -11,6 +11,14 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
-----------------------
2015-10-27 Uwe Stöhr <uwestoehr@web.de>
* Format incremented to 499
No new parameters.
moderncv layout improvements:
- new style Name ,obsoletes the styles FamilyName and FirstName
- new argument for style Phone, obsoletes styles Mobile and Fax
- new styles CVIcons and CVColumnWidth
2015-10-19 Uwe Stöhr <uwestoehr@web.de>
* Format incremented to 498
No new parameters.

View File

@ -2,12 +2,8 @@
\lyxformat 498
\begin_document
\begin_header
\origin unavailable
\origin /systemlyxdir/examples/
\textclass moderncv
\begin_preamble
% uncomment if you want to change the width of the column with the dates:
%\setlength{\hintscolumnwidth}{3cm}
\end_preamble
\use_default_options false
\maintain_unincluded_children false
\language english
@ -81,9 +77,8 @@
status open
\begin_layout Plain Layout
The moderncv class offers lots of customization possibilities; one is explained
in the preamble of this document; for more information look at the documentatio
n of the \SpecialChar LaTeX
The moderncv class offers lots of customization possibilities; for more
information look at the documentation of the \SpecialChar LaTeX
-package
\series bold
moderncv
@ -112,6 +107,24 @@ http://mirrors.ctan.org/macros/latex/contrib/moderncv/examples/template.tex
\end_layout
\begin_layout CVStyle
\begin_inset Note Note
status collapsed
\begin_layout Plain Layout
\begin_inset Argument 1
status open
\begin_layout Plain Layout
left
\end_layout
\end_inset
options can only be activated if moderncv 2.0 is installed
\end_layout
\end_inset
casual
\begin_inset Note Note
status open
@ -124,6 +137,21 @@ required, possible styles are 'casual' (default), 'classic', 'fancy' ('fancy'
\end_inset
\begin_inset Note Note
status collapsed
\begin_layout Plain Layout
To be able to use style options you need at least moderncv version 2.0 installed.
A list of possible options can be found here:
\begin_inset Newline newline
\end_inset
http://article.gmane.org/gmane.comp.tex.ctan.announce/11898
\end_layout
\end_inset
\end_layout
\begin_layout CVColor
@ -139,6 +167,40 @@ required, possible colors are 'blue' (default), 'orange', 'green', 'red',
\end_inset
\end_layout
\begin_layout CVIcons
awesome
\begin_inset Note Note
status collapsed
\begin_layout Plain Layout
optional, must be inserted after the
\family sans
CV Style
\family default
, possible icon sets are 'awesome' (default for style 'casual' and 'banking'),
'marvosym' (default for the other styles) and 'letters' (default for style
'oldstyle')
\end_layout
\end_inset
\end_layout
\begin_layout CVColumnWidth
3cm
\begin_inset Note Note
status collapsed
\begin_layout Plain Layout
optional, the width of the column with the dates, default is '3cm'
\end_layout
\end_inset
\end_layout
\begin_layout PDF Page Mode
@ -203,11 +265,16 @@ Fonts.
\end_layout
\begin_layout FirstName
\begin_layout Name
\begin_inset Argument 1
status open
\begin_layout Plain Layout
Paul
\end_layout
\begin_layout FamilyName
\end_inset
Testman
\end_layout
@ -285,7 +352,16 @@ oldstyle
\end_layout
\begin_layout Mobile
\begin_layout Phone
\begin_inset Argument 1
status open
\begin_layout Plain Layout
mobile
\end_layout
\end_inset
+43(0)999 888
\end_layout
@ -293,7 +369,16 @@ oldstyle
+43(0)999 9999
\end_layout
\begin_layout Fax
\begin_layout Phone
\begin_inset Argument 1
status open
\begin_layout Plain Layout
fax
\end_layout
\end_inset
+43(0)999 7777
\end_layout

View File

@ -48,6 +48,10 @@ Style CVStyle
Series Bold
Color Blue
EndFont
Argument 1
LabelString "Style Options"
Tooltip "Options for the CV style"
EndArgument
End
Style CVColor
@ -56,15 +60,27 @@ Style CVColor
LabelString "CV Color Scheme:"
End
Style CVIcons
CopyStyle CVStyle
LatexName moderncvicons
LabelString "CV Icon Set:"
End
Style CVColumnWidth
CopyStyle CVStyle
LatexName setlength{\hintscolumnwidth}
LabelString "Column Width:"
End
Style PDF_Page_Mode
CopyStyle CVStyle
LatexName renewcommand{\pdfpagemode}
LabelString "PDF Page Mode:"
End
Style FirstName
Style Name
LatexType command
LatexName firstname
LatexName name
Category FrontMatter
InPreamble 1
TopSep 0.7
@ -73,6 +89,18 @@ Style FirstName
Family Sans
Size Largest
EndFont
Argument 1
LabelString "First Name"
Tooltip "First name"
Mandatory 1
EndArgument
End
Style FirstName
CopyStyle Name
LatexName firstname
ResetArgs 0
ObsoletedBy Name
End
Style FamilyName
@ -80,6 +108,7 @@ Style FamilyName
LatexName familyname
TopSep 0.3
LabelString "Family Name:"
ObsoletedBy Name
End
Style Title
@ -121,22 +150,28 @@ Style Address
EndArgument
End
Style Mobile
CopyStyle CVStyle
LatexName mobile
LabelString "Mobile:"
End
Style Phone
CopyStyle CVStyle
LatexName phone
LabelString "Phone:"
Argument 1
LabelString "Phone Type"
Tooltip "can be fixed, mobile or fax"
EndArgument
End
Style Mobile
CopyStyle CVStyle
LatexName mobile
LabelString "Mobile:"
ObsoletedBy Phone
End
Style Fax
CopyStyle CVStyle
LatexName fax
LabelString "Fax:"
ObsoletedBy Phone
End
Style Email

View File

@ -1,6 +1,6 @@
# This file is part of lyx2lyx
# -*- coding: utf-8 -*-
# Copyright (C) 2002-2011 The LyX Team
# Copyright (C) 2002-2015 The LyX Team
# Copyright (C) 2002-2004 Dekel Tsur <dekel@lyx.org>
# Copyright (C) 2002-2006 José Matos <jamatos@lyx.org>
#
@ -85,7 +85,7 @@ format_relation = [("0_06", [200], minor_versions("0.6" , 4)),
("1_6", list(range(277,346)), minor_versions("1.6" , 10)),
("2_0", list(range(346,414)), minor_versions("2.0" , 8)),
("2_1", list(range(414,475)), minor_versions("2.1" , 0)),
("2_2", list(range(475,499)), minor_versions("2.2" , 0))
("2_2", list(range(475,500)), minor_versions("2.2" , 0))
]
####################################################################

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# This file is part of lyx2lyx
# -*- coding: utf-8 -*-
# Copyright (C) 2011 The LyX team
# Copyright (C) 2015 The LyX team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -1812,6 +1812,187 @@ def revert_tcolorbox_8(document):
return
def revert_moderncv_1(document):
" Reverts the new inset of moderncv to TeX-code in preamble "
if document.textclass != "moderncv":
return
i = 0
j = 0
lineArg = 0
while True:
# at first revert the new styles
# \moderncvicons
i = find_token(document.body, "\\begin_layout CVIcons", 0)
if i == -1:
return
j = find_end_of_layout(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of CVIcons layout")
i += 1
continue
content = lyx2latex(document, document.body[i:j + 1])
add_to_preamble(document, ["\\moderncvicons{" + content + "}"])
del document.body[i:j + 1]
# \hintscolumnwidth
i = find_token(document.body, "\\begin_layout CVColumnWidth", 0)
if i == -1:
return
j = find_end_of_layout(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of CVColumnWidth layout")
i += 1
continue
content = lyx2latex(document, document.body[i:j + 1])
add_to_preamble(document, ["\\setlength{\hintscolumnwidth}{" + content + "}"])
del document.body[i:j + 1]
# now change the new styles to the obsolete ones
# \name
i = find_token(document.body, "\\begin_layout Name", 0)
if i == -1:
return
j = find_end_of_layout(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of Name layout")
i += 1
continue
lineArg = find_token(document.body, "\\begin_inset Argument 1", i)
if lineArg > j and j != 0:
return
if lineArg != -1:
beginPlain = find_token(document.body, "\\begin_layout Plain Layout", lineArg)
# we have to assure that no other inset is in the Argument
beginInset = find_token(document.body, "\\begin_inset", beginPlain)
endInset = find_token(document.body, "\\end_inset", beginPlain)
k = beginPlain + 1
l = k
while beginInset < endInset and beginInset != -1:
beginInset = find_token(document.body, "\\begin_inset", k)
endInset = find_token(document.body, "\\end_inset", l)
k = beginInset + 1
l = endInset + 1
Arg2 = document.body[l + 5 : l + 6]
# rename the style
document.body[i : i + 1]= ["\\begin_layout FirstName"]
# delete the Argument inset
del( document.body[endInset - 2 : endInset + 3])
del( document.body[lineArg : beginPlain + 1])
document.body[i + 4 : i + 4]= ["\\begin_layout FamilyName"] + Arg2 + ["\\end_layout"] + [""]
def revert_moderncv_2(document):
" Reverts the phone inset of moderncv to the obsoleted mobile or fax "
if document.textclass != "moderncv":
return
i = 0
j = 0
lineArg = 0
while True:
# \phone
i = find_token(document.body, "\\begin_layout Phone", i)
if i == -1:
return
j = find_end_of_layout(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of Phone layout")
i += 1
return
lineArg = find_token(document.body, "\\begin_inset Argument 1", i)
if lineArg > j and j != 0:
i += 1
continue
if lineArg != -1:
beginPlain = find_token(document.body, "\\begin_layout Plain Layout", lineArg)
# we have to assure that no other inset is in the Argument
beginInset = find_token(document.body, "\\begin_inset", beginPlain)
endInset = find_token(document.body, "\\end_inset", beginPlain)
k = beginPlain + 1
l = k
while beginInset < endInset and beginInset != -1:
beginInset = find_token(document.body, "\\begin_inset", k)
endInset = find_token(document.body, "\\end_inset", l)
k = beginInset + 1
l = endInset + 1
Arg = document.body[beginPlain + 1 : beginPlain + 2]
# rename the style
if Arg[0] == "mobile":
document.body[i : i + 1]= ["\\begin_layout Mobile"]
if Arg[0] == "fax":
document.body[i : i + 1]= ["\\begin_layout Fax"]
# delete the Argument inset
del(document.body[endInset - 2 : endInset + 1])
del(document.body[lineArg : beginPlain + 3])
i += 1
def convert_moderncv(document):
" Convert the Fax and Mobile inset of moderncv to the new phone inset "
if document.textclass != "moderncv":
return
i = 0
j = 0
lineArg = 0
while True:
# \mobile
i = find_token(document.body, "\\begin_layout Mobile", i)
if i == -1:
return
j = find_end_of_layout(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of Mobile layout")
i += 1
return
document.body[i + 1 : i + 1] = ["\\begin_inset Argument 1", "status open", "",
"\\begin_layout Plain Layout", "mobile", "\\end_layout", "",
"\\end_inset", ""]
# \fax
i = find_token(document.body, "\\begin_layout Fax", i)
if i == -1:
return
j = find_end_of_layout(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of Fax layout")
i += 1
return
document.body[i + 1 : i + 1] = ["\\begin_inset Argument 1", "status open", "",
"\\begin_layout Plain Layout", "fax", "\\end_layout", "",
"\\end_inset", ""]
# \firstname and \familyname
i1 = find_token(document.body, "\\begin_layout FirstName", 0)
if i1 == -1:
return
j1 = find_end_of_layout(document.body, i1)
if j1 == -1:
document.warning("Malformed LyX document: Can't find end of FirstName layout")
i1 += 1
return
FirstName = document.body[i1 + 1 : i1 + 2]
i2 = find_token(document.body, "\\begin_layout FamilyName", 0)
if i2 == -1:
return
j2 = find_end_of_layout(document.body, i2)
if j2 == -1:
document.warning("Malformed LyX document: Can't find end of FamilyName layout")
i2 += 1
return
FamilyName = document.body[i2 + 1 : i2 + 2]
if j1 > j2:
k = j1
l = i2
else:
k = j2
l = i1
document.body[k + 1 : k + 1] = ["\\begin_layout Name", "\\begin_inset Argument 1", "status open", "",
"\\begin_layout Plain Layout", FirstName[0], "\\end_layout", "",
"\\end_inset", "", FamilyName[0], "\\end_layout", ""]
#document.body[i2 + 1 : i2 + 1] = ["hellok: ", str(k)]
del(document.body[l : k])
i += 1
i1 += 1
i2 += 1
##
# Conversion hub
#
@ -1844,10 +2025,12 @@ convert = [
[495, [convert_subref]],
[496, [convert_nounzip]],
[497, [convert_external_bbox]],
[498, []]
[498, []],
[499, [convert_moderncv]]
]
revert = [
[498, [revert_moderncv_1, revert_moderncv_2]],
[497, [revert_tcolorbox_1, revert_tcolorbox_2,
revert_tcolorbox_3, revert_tcolorbox_4, revert_tcolorbox_5,
revert_tcolorbox_6, revert_tcolorbox_7, revert_tcolorbox_8]],

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 498
\lyxformat 499
\begin_document
\begin_header
\origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 498
\lyxformat 499
\begin_document
\begin_header
\origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 498
\lyxformat 499
\begin_document
\begin_header
\origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 498
\lyxformat 499
\begin_document
\begin_header
\origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 498
\lyxformat 499
\begin_document
\begin_header
\origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 498
\lyxformat 499
\begin_document
\begin_header
\origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 498
\lyxformat 499
\begin_document
\begin_header
\origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 498
\lyxformat 499
\begin_document
\begin_header
\origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 498
\lyxformat 499
\begin_document
\begin_header
\origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 498
\lyxformat 499
\begin_document
\begin_header
\origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 498
\lyxformat 499
\begin_document
\begin_header
\origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 498
\lyxformat 499
\begin_document
\begin_header
\origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 498
\lyxformat 499
\begin_document
\begin_header
\origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 498
\lyxformat 499
\begin_document
\begin_header
\origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 498
\lyxformat 499
\begin_document
\begin_header
\origin roundtrip

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 498
\lyxformat 499
\begin_document
\begin_header
\origin roundtrip

View File

@ -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 498 // uwestoehr: tcolorbox module improvements
#define LYX_FORMAT_TEX2LYX 498
#define LYX_FORMAT_LYX 499 // uwestoehr: moderncv module improvements
#define LYX_FORMAT_TEX2LYX 499
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER