improve classic theme

This commit is contained in:
Sina Atalay 2023-11-17 01:04:43 +01:00 committed by Jeffrey Goldberg
parent b4042f704e
commit fe5c182a51
3 changed files with 78 additions and 41 deletions

View File

@ -265,6 +265,59 @@ def abbreviate_names(names: list[str]) -> str:
return abbreviated_names return abbreviated_names
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.
@ -468,12 +521,12 @@ def run_latex(latex_file_path: str) -> str:
error_line = line.replace("! ", "") error_line = line.replace("! ", "")
break break
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.",
) )
run() run()
run() # run twice for cross-references run() # run twice for cross-references

View File

@ -11,8 +11,7 @@
bottom=<<theme_options.margins.page.bottom>>, % seperation between body and page edge from the bottom bottom=<<theme_options.margins.page.bottom>>, % seperation between body and page edge from the bottom
left=<<theme_options.margins.page.left>>, % seperation between body and page edge from the left left=<<theme_options.margins.page.left>>, % seperation between body and page edge from the left
right=<<theme_options.margins.page.right>>, % seperation between body and page edge from the right right=<<theme_options.margins.page.right>>, % seperation between body and page edge from the right
footskip=<<theme_options.margins.page.bottom|divide_length_by(2)>>, % seperation between body and footer % showframe % for debugging
% showframe % for debugging
]{geometry} % for adjusting page geometry ]{geometry} % for adjusting page geometry
\usepackage{fontspec} % for loading fonts \usepackage{fontspec} % for loading fonts
\usepackage[explicit]{titlesec} % for customizing section titles \usepackage[explicit]{titlesec} % for customizing section titles
@ -30,22 +29,14 @@
]{hyperref} % for links, metadata and bookmarks ]{hyperref} % for links, metadata and bookmarks
\usepackage[pscoord]{eso-pic} % for floating text on the page \usepackage[pscoord]{eso-pic} % for floating text on the page
\usepackage{calc} % for calculating lengths \usepackage{calc} % for calculating lengths
\usepackage{bookmark} % for bookmarks
\usepackage{lastpage} % for getting the total number of pages
% Some settings: % Some settings:
\pagestyle{empty} % no header or footer \pagestyle{empty} % no header or footer
\setcounter{secnumdepth}{0} % no section numbering \setcounter{secnumdepth}{0} % no section numbering
\setlength{\parindent}{0pt} % no indentation \setlength{\parindent}{0pt} % no indentation
\setlength{\topskip}{0pt} % no top skip \setlength{\topskip}{0pt} % no top skip
((# \pagenumbering{gobble} % no page numbering #)) \pagenumbering{gobble} % no page numbering
\makeatletter
\let\ps@customFooterStyle\ps@plain % Copy the plain style to customFooterStyle
\patchcmd{\ps@customFooterStyle}{\thepage}{
\color{gray}\textit{\small <<cv.name>> | Page \thepage{} of \pageref*{LastPage}}
}{}{} % replace number by desired string
\makeatother
\pagestyle{customFooterStyle}
\setmainfont{<<design.font>>}[ \setmainfont{<<design.font>>}[
Path= fonts/, Path= fonts/,
@ -84,23 +75,18 @@
\newcolumntype{R}[1]{ \newcolumntype{R}[1]{
>{\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
((* if theme_options.text_alignment == "justified" *))
\newcolumntype{K}[1]{ \newcolumntype{K}[1]{
>{\let\newline\\\arraybackslash\hspace{0pt}}X >{\let\newline\\\arraybackslash\hspace{0pt}}X
} % justified flexible width column type } % left-aligned (but justified) flexible width column type
((* elif theme_options.text_alignment == "left-aligned" *))
\newcolumntype{K}[1]{
>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}X
} % left-aligned flexible width column type
((* endif *))
\setlength\tabcolsep{-1.5pt} % no space between columns \setlength\tabcolsep{-1.5pt} % no space between columns
\newenvironment{highlights}{ \newenvironment{highlights}{
\begin{itemize}[ \begin{itemize}[
topsep=0pt, topsep=0pt,
parsep=<<theme_options.margins.highlights_area.vertical_between_bullet_points>>, parsep=<<theme_options.margins.highlights_area.vertical_between_bullet_points>>,
partopsep=0pt, partopsep=0pt,
itemsep=0pt, itemsep=0pt,
after=\vspace{-1\baselineskip}, after=\vspace*{-1\baselineskip},
leftmargin=<<theme_options.margins.highlights_area.left>> + 3pt leftmargin=<<theme_options.margins.highlights_area.left>> + 3pt
] ]
}{ }{
@ -119,7 +105,7 @@
\LenToUnit{\paperwidth-<<theme_options.margins.page.right>>-<<theme_options.margins.entry_area.left_and_right>>+0.05cm}, \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}\textit{Last updated on <<today>>}\hspace{\widthof{Last updated on <<today>>}} \small\color{gray}\emph{Last updated on <<today>>}\hspace{\widthof{Last updated on <<today>>}}
}}}% }}}%
}% }%
}% }%
@ -127,7 +113,7 @@
% save the original href command in a new command: % save the original href command in a new command:
\let\hrefWithoutArrow\href \let\hrefWithoutArrow\href
% new command for external links: % new command for external links:
\renewcommand{\href}[2]{\hrefWithoutArrow{#1}{#2 \raisebox{.15ex}{\footnotesize \faExternalLink*}}} \renewcommand{\href}[2]{\hrefWithoutArrow{#1}{#2\, \raisebox{.1ex}{\footnotesize \faExternalLink*}}}
\begin{document} \begin{document}
((* if theme_options.show_last_updated_date *)) ((* if theme_options.show_last_updated_date *))
@ -135,13 +121,9 @@
((* endif *)) ((* endif *))
<<header(name=cv.name, connections=cv.connections)|indent(4)>> <<header(name=cv.name, connections=cv.connections)|indent(4)>>
((* if cv.summary is not none *)) ((* if cv.summary is not none *))
\section{Summary} \section{Summary}
{
((* if theme_options.text_alignment == "left-aligned" *))
\raggedright
((* endif *))
\setlength{\leftskip}{<<theme_options.margins.entry_area.left_and_right>>} \setlength{\leftskip}{<<theme_options.margins.entry_area.left_and_right>>}
\setlength{\rightskip}{<<theme_options.margins.entry_area.left_and_right>>} \setlength{\rightskip}{<<theme_options.margins.entry_area.left_and_right>>}
@ -149,7 +131,6 @@
\setlength{\leftskip}{0cm} \setlength{\leftskip}{0cm}
\setlength{\rightskip}{0cm} \setlength{\rightskip}{0cm}
}
((* endif *)) ((* endif *))
\centering \centering

View File

@ -7,6 +7,7 @@
((# 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_and_right>>}; variable width, justified column #)) ((# second column: K{<<theme_options.margins.entry_area.left_and_right>>}; variable width, justified 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-<<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>>}} \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>>}
@ -25,7 +26,7 @@
((# first column:: K{<<theme_options.margins.entry_area.left_and_right>>}; variable width, justified 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-<<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>>}} \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|markdown_to_latex>>}, <<position|markdown_to_latex>> \textbf{<<company>>}, <<position>>
<<print_higlights(highlights)|indent(4)->> <<print_higlights(highlights)|indent(4)->>
& &
<<print_date_and_locations(date_and_location_strings)|indent(4)->> <<print_date_and_locations(date_and_location_strings)|indent(4)->>
@ -43,12 +44,12 @@
((* 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 +")" *))
\textbf{<<name|markdown_to_latex>>}, <<markdown_url|markdown_to_latex>> \textbf{<<name>>}, <<markdown_url|markdown_to_latex>>
((* else *)) ((* else *))
\textbf{<<name|markdown_to_latex>>}, <<markdown_url|markdown_to_latex>> \textbf{<<name>>}, <<markdown_url|markdown_to_latex>>
((* endif *)) ((* endif *))
((* else *)) ((* else *))
\textbf{<<name|markdown_to_latex>>} \textbf{<<name>>}
((* endif *)) ((* endif *))
<<print_higlights(highlights)|indent(4)->> <<print_higlights(highlights)|indent(4)->>
\end{tabularx} \end{tabularx}
@ -80,9 +81,11 @@
\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>>}} \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>>}
\vspace{<<theme_options.margins.highlights_area.vertical_between_bullet_points>>} \vspace{<<theme_options.margins.entry_area.vertical_between|divide_length_by(2)>>}
<<authors|abbreviate_names|join(", ")|make_it_bold(cv.name|abbreviate_name)|make_it_italic(cv.name|abbreviate_name)>> <<authors|abbreviate_names|join(", ")|make_it_italic(cv.name|abbreviate_name)>>
\vspace{<<theme_options.margins.entry_area.vertical_between|divide_length_by(2)>>}
\vspace{<<theme_options.margins.highlights_area.vertical_between_bullet_points>>} \vspace{<<theme_options.margins.highlights_area.vertical_between_bullet_points>>}
@ -94,7 +97,7 @@
((* endmacro *)) ((* endmacro *))
((* macro one_line(name, details, markdown_url=none, link_text=none) *)) ((* macro one_line(name, details, markdown_url=none, link_text=none) *))
\begingroup((* if theme_options.text_alignment == "left-aligned" *))\raggedright((* endif *)) \begingroup\raggedright
\leftskip=<<theme_options.margins.entry_area.left_and_right>> \leftskip=<<theme_options.margins.entry_area.left_and_right>>
\advance\csname @rightskip\endcsname <<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>> \advance\rightskip <<theme_options.margins.entry_area.left_and_right>>