mirror of https://github.com/eyhc1/rendercv.git
improve classic theme
This commit is contained in:
parent
631e9d594c
commit
0af0fcffec
|
@ -212,6 +212,59 @@ def make_it_italic(value: str, match_str: Optional[str] = None) -> str:
|
||||||
return make_it_something(value, "make_it_italic", match_str)
|
return make_it_something(value, "make_it_italic", match_str)
|
||||||
|
|
||||||
|
|
||||||
|
def abbreviate_name(name: list[str]) -> str:
|
||||||
|
"""Abbreviate a name by keeping the first letters of the first names.
|
||||||
|
|
||||||
|
This function is used as a Jinja2 filter.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```python
|
||||||
|
abbreviate_name("John Doe")
|
||||||
|
```
|
||||||
|
|
||||||
|
will return:
|
||||||
|
|
||||||
|
`#!python "J. Doe"`
|
||||||
|
|
||||||
|
Args:
|
||||||
|
name (str): The name to abbreviate.
|
||||||
|
Returns:
|
||||||
|
str: The abbreviated name.
|
||||||
|
"""
|
||||||
|
first_names = name.split(" ")[:-1]
|
||||||
|
first_names_initials = [first_name[0] + "." for first_name in first_names]
|
||||||
|
last_name = name.split(" ")[-1]
|
||||||
|
abbreviated_name = " ".join(first_names_initials) + " " + last_name
|
||||||
|
|
||||||
|
return abbreviated_name
|
||||||
|
|
||||||
|
|
||||||
|
def abbreviate_names(names: list[str]) -> str:
|
||||||
|
"""Abbreviate a list of names by keeping the first letters of the first names.
|
||||||
|
|
||||||
|
This function is used as a Jinja2 filter.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```python
|
||||||
|
abbreviate_names(["John Doe", "Jane Atalay"])
|
||||||
|
```
|
||||||
|
|
||||||
|
will return:
|
||||||
|
|
||||||
|
`#!python ["J. Doe", "J. Atalay"]`
|
||||||
|
|
||||||
|
Args:
|
||||||
|
names (list[str]): The names to abbreviate.
|
||||||
|
Returns:
|
||||||
|
str: The list of abbreviated names.
|
||||||
|
"""
|
||||||
|
abbreviated_names = []
|
||||||
|
for name in names:
|
||||||
|
abbreviated_names.append(abbreviate_name(name))
|
||||||
|
|
||||||
|
return abbreviated_names
|
||||||
|
|
||||||
|
|
||||||
def divide_length_by(length: str, divider: float) -> str:
|
def divide_length_by(length: str, divider: float) -> str:
|
||||||
r"""Divide a length by a number.
|
r"""Divide a length by a number.
|
||||||
|
|
||||||
|
@ -282,6 +335,8 @@ def render_template(data: RenderCVDataModel, output_path: Optional[str] = None)
|
||||||
environment.filters["make_it_underlined"] = make_it_underlined
|
environment.filters["make_it_underlined"] = make_it_underlined
|
||||||
environment.filters["make_it_italic"] = make_it_italic
|
environment.filters["make_it_italic"] = make_it_italic
|
||||||
environment.filters["divide_length_by"] = divide_length_by
|
environment.filters["divide_length_by"] = divide_length_by
|
||||||
|
environment.filters["abbreviate_name"] = abbreviate_name
|
||||||
|
environment.filters["abbreviate_names"] = abbreviate_names
|
||||||
|
|
||||||
# load the template:
|
# load the template:
|
||||||
template = environment.get_template(f"{theme}.tex.j2")
|
template = environment.get_template(f"{theme}.tex.j2")
|
||||||
|
@ -411,10 +466,8 @@ def run_latex(latex_file_path: str) -> str:
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
"Running TinyTeX has failed with the following error:",
|
"Running TinyTeX has failed with the following error:",
|
||||||
f"{error_line}",
|
f"{error_line}",
|
||||||
(
|
"If you can't solve the problem, please try to re-install RenderCV,"
|
||||||
"If you can't solve the problem, please try to re-install RenderCV,"
|
" or open an issue on GitHub.",
|
||||||
" or open an issue on GitHub."
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# check if the PDF file is generated:
|
# check if the PDF file is generated:
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
}{
|
}{
|
||||||
% print bold title, give 0.15 cm space and draw a line of 0.8 pt thickness
|
% print bold title, give 0.15 cm space and draw a line of 0.8 pt thickness
|
||||||
% from the end of the title to the end of the body
|
% from the end of the title to the end of the body
|
||||||
\textbf{#1}\hspace{0.15cm}\titlerule[0.8pt]
|
\textbf{#1}\hspace{0.15cm}\titlerule[0.8pt]\hspace{-0.1cm}
|
||||||
}[] % section title formatting
|
}[] % section title formatting
|
||||||
|
|
||||||
\titlespacing{\section}{
|
\titlespacing{\section}{
|
||||||
|
@ -76,8 +76,9 @@
|
||||||
>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}p{#1}
|
>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}p{#1}
|
||||||
} % right-aligned fixed width column type
|
} % right-aligned fixed width column type
|
||||||
\newcolumntype{K}[1]{
|
\newcolumntype{K}[1]{
|
||||||
>{\raggedright\let\newline\\\arraybackslash\hspace{-0.2cm}\hspace{#1}}X
|
>{\let\newline\\\arraybackslash\hspace{0pt}}X
|
||||||
} % left-aligned flexible width column type
|
} % left-aligned (but justified) flexible width column type
|
||||||
|
\setlength\tabcolsep{-1.5pt} % no space between columns
|
||||||
|
|
||||||
\newenvironment{highlights}{
|
\newenvironment{highlights}{
|
||||||
\begin{itemize}[
|
\begin{itemize}[
|
||||||
|
@ -101,10 +102,10 @@
|
||||||
\newcommand{\placelastupdatedtext}{% \placetextbox{<horizontal pos>}{<vertical pos>}{<stuff>}
|
\newcommand{\placelastupdatedtext}{% \placetextbox{<horizontal pos>}{<vertical pos>}{<stuff>}
|
||||||
\AddToShipoutPictureFG*{% Add <stuff> to current page foreground
|
\AddToShipoutPictureFG*{% Add <stuff> to current page foreground
|
||||||
\put(
|
\put(
|
||||||
\LenToUnit{\paperwidth-<<theme_options.margins.page.right>>},
|
\LenToUnit{\paperwidth-<<theme_options.margins.page.right>>-<<theme_options.margins.entry_area.left_and_right>>+0.05cm},
|
||||||
\LenToUnit{\paperheight-<<theme_options.margins.page.top|divide_length_by(2)>>}
|
\LenToUnit{\paperheight-<<theme_options.margins.page.top|divide_length_by(2)>>}
|
||||||
){\vtop{{\null}\makebox[0pt][c]{
|
){\vtop{{\null}\makebox[0pt][c]{
|
||||||
\small\color{gray}\emph{Last updated on <<today>>} \hspace{\widthof{Last updated on <<today>>}}
|
\small\color{gray}\emph{Last updated on <<today>>}\hspace{\widthof{Last updated on <<today>>}}
|
||||||
}}}%
|
}}}%
|
||||||
}%
|
}%
|
||||||
}%
|
}%
|
||||||
|
@ -123,8 +124,8 @@
|
||||||
((* if cv.summary is not none *))
|
((* if cv.summary is not none *))
|
||||||
\section{Summary}
|
\section{Summary}
|
||||||
|
|
||||||
\setlength{\leftskip}{<<theme_options.margins.entry_area.left>>}
|
\setlength{\leftskip}{<<theme_options.margins.entry_area.left_and_right>>}
|
||||||
\setlength{\rightskip}{<<theme_options.margins.entry_area.right>>}
|
\setlength{\rightskip}{<<theme_options.margins.entry_area.left_and_right>>}
|
||||||
|
|
||||||
<<cv.summary>>
|
<<cv.summary>>
|
||||||
|
|
||||||
|
@ -132,6 +133,7 @@
|
||||||
\setlength{\rightskip}{0cm}
|
\setlength{\rightskip}{0cm}
|
||||||
((* endif *))
|
((* endif *))
|
||||||
|
|
||||||
|
\centering
|
||||||
((* for section in cv.sections *))
|
((* for section in cv.sections *))
|
||||||
\section{<<section.title>>}
|
\section{<<section.title>>}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
((* macro date_and_location_strings(date_and_location_strings) *))
|
((* macro date_and_location_strings(date_and_location_strings) *))
|
||||||
((* for item in date_and_location_strings *))
|
((* for item in date_and_location_strings *))
|
||||||
((* if loop.last *))
|
((* if loop.last *))
|
||||||
<<item>> \hspace*{-0.2cm + <<theme_options.margins.entry_area.right>>}
|
<<item>>
|
||||||
((* else *))
|
((* else *))
|
||||||
<<item>> \hspace*{-0.2cm + <<theme_options.margins.entry_area.right>>} \newline
|
<<item>> \newline
|
||||||
((* endif *))
|
((* endif *))
|
||||||
((* endfor *))
|
((* endfor *))
|
||||||
((* endmacro *))
|
((* endmacro *))
|
|
@ -6,9 +6,9 @@
|
||||||
((# width: \textwidth #))
|
((# width: \textwidth #))
|
||||||
((# preamble: first column, second column, third column #))
|
((# preamble: first column, second column, third column #))
|
||||||
((# first column: p{0.55cm}; constant width, ragged left column #))
|
((# first column: p{0.55cm}; constant width, ragged left column #))
|
||||||
((# second column: K{<<theme_options.margins.entry_area.left>>}; variable width, ragged left column #))
|
((# second column: K{<<theme_options.margins.entry_area.left_and_right>>}; variable width, justified column #))
|
||||||
((# third column: R{<<theme_options.date_and_location_width>>}; constant widthm ragged right column #))
|
((# third column: R{<<theme_options.date_and_location_width>>}; constant widthm ragged right column #))
|
||||||
\begin{tabularx}{\textwidth}{p{0.55cm} K{<<theme_options.margins.entry_area.left>>} R{<<theme_options.date_and_location_width>>}}
|
\begin{tabularx}{\textwidth-<<theme_options.margins.entry_area.left_and_right|divide_length_by(0.5)>>-0.13cm}{L{0.85cm} K{<<theme_options.margins.entry_area.left_and_right>>} R{<<theme_options.date_and_location_width>>}}
|
||||||
\textbf{<<study_type if study_type is not none>>}
|
\textbf{<<study_type if study_type is not none>>}
|
||||||
&
|
&
|
||||||
\textbf{<<institution>>}, <<area>>
|
\textbf{<<institution>>}, <<area>>
|
||||||
|
@ -22,9 +22,9 @@
|
||||||
((# \begin{tabularx}{⟨width⟩}[⟨pos⟩]{⟨preamble⟩} #))
|
((# \begin{tabularx}{⟨width⟩}[⟨pos⟩]{⟨preamble⟩} #))
|
||||||
((# width: \textwidth #))
|
((# width: \textwidth #))
|
||||||
((# preamble: first column, second column #))
|
((# preamble: first column, second column #))
|
||||||
((# first column:: K{<<theme_options.margins.entry_area.left>>}; variable width, ragged left column #))
|
((# first column:: K{<<theme_options.margins.entry_area.left_and_right>>}; variable width, justified column #))
|
||||||
((# second column: R{<<theme_options.date_and_location_width>>}; constant width ragged right column #))
|
((# second column: R{<<theme_options.date_and_location_width>>}; constant width ragged right column #))
|
||||||
\begin{tabularx}{\textwidth}{K{<<theme_options.margins.entry_area.left>>} R{<<theme_options.date_and_location_width>>}}
|
\begin{tabularx}{\textwidth-<<theme_options.margins.entry_area.left_and_right|divide_length_by(0.5)>>-0.13cm}{K{<<theme_options.margins.entry_area.left_and_right>>} R{<<theme_options.date_and_location_width>>}}
|
||||||
\textbf{<<company>>}, <<position>>
|
\textbf{<<company>>}, <<position>>
|
||||||
<<print_higlights(highlights)|indent(4)->>
|
<<print_higlights(highlights)|indent(4)->>
|
||||||
&
|
&
|
||||||
|
@ -36,9 +36,24 @@
|
||||||
((# \begin{tabularx}{⟨width⟩}[⟨pos⟩]{⟨preamble⟩} #))
|
((# \begin{tabularx}{⟨width⟩}[⟨pos⟩]{⟨preamble⟩} #))
|
||||||
((# width: \textwidth #))
|
((# width: \textwidth #))
|
||||||
((# preamble: first column, second column #))
|
((# preamble: first column, second column #))
|
||||||
((# first column:: K{<<theme_options.margins.entry_area.left>>}; variable width, ragged left column #))
|
((# first column:: K{<<theme_options.margins.entry_area.left_and_right>>}; variable width, justified column #))
|
||||||
((# second column: R{<<theme_options.date_and_location_width>>}; constant width ragged right column #))
|
((# second column: R{<<theme_options.date_and_location_width>>}; constant width ragged right column #))
|
||||||
\begin{tabularx}{\textwidth}{K{<<theme_options.margins.entry_area.left>>} R{<<theme_options.date_and_location_width>>}}
|
((* if date_and_location_strings == [] *))
|
||||||
|
\begin{tabularx}{\textwidth-<<theme_options.margins.entry_area.left_and_right|divide_length_by(0.5)>>-0.13cm}{K{<<theme_options.margins.entry_area.left_and_right>>}}
|
||||||
|
((* if markdown_url is not none *))
|
||||||
|
((* if link_text is not none *))
|
||||||
|
((* set markdown_url = "["+link_text+"]("+ markdown_url|markdown_link_to_url +")" *))
|
||||||
|
\textbf{<<name>>}, <<markdown_url|markdown_to_latex>>
|
||||||
|
((* else *))
|
||||||
|
\textbf{<<name>>}, <<markdown_url|markdown_to_latex>>
|
||||||
|
((* endif *))
|
||||||
|
((* else *))
|
||||||
|
\textbf{<<name>>}
|
||||||
|
((* endif *))
|
||||||
|
<<print_higlights(highlights)|indent(4)->>
|
||||||
|
\end{tabularx}
|
||||||
|
((* else *))
|
||||||
|
\begin{tabularx}{\textwidth-<<theme_options.margins.entry_area.left_and_right|divide_length_by(0.5)>>-0.13cm}{K{<<theme_options.margins.entry_area.left_and_right>>} R{<<theme_options.date_and_location_width>>}}
|
||||||
((* if markdown_url is not none *))
|
((* if markdown_url is not none *))
|
||||||
((* if link_text is not none *))
|
((* if link_text is not none *))
|
||||||
((* set markdown_url = "["+link_text+"]("+ markdown_url|markdown_link_to_url +")" *))
|
((* set markdown_url = "["+link_text+"]("+ markdown_url|markdown_link_to_url +")" *))
|
||||||
|
@ -53,28 +68,36 @@
|
||||||
&
|
&
|
||||||
<<print_date_and_locations(date_and_location_strings)|indent(4)->>
|
<<print_date_and_locations(date_and_location_strings)|indent(4)->>
|
||||||
\end{tabularx}
|
\end{tabularx}
|
||||||
|
((* endif *))
|
||||||
((* endmacro *))
|
((* endmacro *))
|
||||||
|
|
||||||
((* macro publication(title, authors, journal, date, doi, doi_url)*))
|
((* macro publication(title, authors, journal, date, doi, doi_url)*))
|
||||||
((# \begin{tabularx}{⟨width⟩}[⟨pos⟩]{⟨preamble⟩} #))
|
((# \begin{tabularx}{⟨width⟩}[⟨pos⟩]{⟨preamble⟩} #))
|
||||||
((# width: \textwidth #))
|
((# width: \textwidth #))
|
||||||
((# preamble: first column, second column #))
|
((# preamble: first column, second column #))
|
||||||
((# first column:: K{<<theme_options.margins.entry_area.left>>}; variable width, ragged left column #))
|
((# first column:: K{<<theme_options.margins.entry_area.left_and_right>>}; variable width, justified column #))
|
||||||
((# second column: R{<<theme_options.date_and_location_width>>}; constant width ragged right column #))
|
((# second column: R{<<theme_options.date_and_location_width>>}; constant width ragged right column #))
|
||||||
\begin{tabularx}{\textwidth}{K{<<theme_options.margins.entry_area.left>>} R{<<theme_options.date_and_location_width>>}}
|
\begin{tabularx}{\textwidth-<<theme_options.margins.entry_area.left_and_right|divide_length_by(0.5)>>-0.13cm}{K{<<theme_options.margins.entry_area.left_and_right>>} R{<<theme_options.date_and_location_width>>}}
|
||||||
\textbf{<<title>>}
|
\textbf{<<title>>}
|
||||||
|
|
||||||
<<authors|join(", ")|make_it_italic(cv.name)>>
|
\vspace{<<theme_options.margins.entry_area.vertical_between|divide_length_by(2)>>}
|
||||||
|
|
||||||
|
<<authors|abbreviate_names|join(", ")|make_it_italic(cv.name|abbreviate_name)>>
|
||||||
|
|
||||||
|
\vspace{<<theme_options.margins.entry_area.vertical_between|divide_length_by(2)>>}
|
||||||
|
|
||||||
DOI: \href{<<doi_url>>}{<<doi>>}
|
DOI: \href{<<doi_url>>}{<<doi>>}
|
||||||
&
|
&
|
||||||
<<date>>
|
<<date>>
|
||||||
|
|
||||||
\end{tabularx}
|
\end{tabularx}
|
||||||
((* endmacro *))
|
((* endmacro *))
|
||||||
|
|
||||||
((* macro one_line(name, details, markdown_url=none, link_text=none)*))
|
((* macro one_line(name, details, markdown_url=none, link_text=none) *))
|
||||||
\setlength{\leftskip}{<<theme_options.margins.entry_area.left>>}
|
\begingroup\raggedright
|
||||||
\setlength{\rightskip}{<<theme_options.margins.entry_area.right>>}
|
\leftskip=<<theme_options.margins.entry_area.left_and_right>>
|
||||||
|
\advance\csname @rightskip\endcsname <<theme_options.margins.entry_area.left_and_right>>
|
||||||
|
\advance\rightskip <<theme_options.margins.entry_area.left_and_right>>
|
||||||
|
|
||||||
((* if markdown_url is not none *))
|
((* if markdown_url is not none *))
|
||||||
((* if link_text is not none *))
|
((* if link_text is not none *))
|
||||||
|
@ -87,6 +110,5 @@
|
||||||
\textbf{<<name>>:} <<details>>
|
\textbf{<<name>>:} <<details>>
|
||||||
((* endif *))
|
((* endif *))
|
||||||
|
|
||||||
\setlength{\leftskip}{0cm}
|
\par\endgroup
|
||||||
\setlength{\rightskip}{0cm}
|
|
||||||
((* endmacro *))
|
((* endmacro *))
|
Loading…
Reference in New Issue