add text alignment options

This commit is contained in:
Sina Atalay 2023-11-20 20:11:08 +01:00
parent 4fb871fb8d
commit 9afec3ba3b
4 changed files with 28 additions and 10 deletions

View File

@ -468,6 +468,12 @@ class ClassicThemeOptions(BaseModel):
description="The width of the date and location column.",
)
text_alignment: Literal["left-aligned", "justified"] = Field(
default="left-aligned",
title="Text Alignment",
description="The alignment of the text.",
)
show_timespan_in: list[str] = Field(
default=[],
title="Show Time Span in These Sections",

View File

@ -11,7 +11,7 @@ from typing import Optional
import sys
from importlib.resources import files
from .data_model import RenderCVDataModel
from .data_model import RenderCVDataModel, CurriculumVitae, Design, ClassicThemeOptions
from jinja2 import Environment, PackageLoader
@ -341,10 +341,13 @@ def render_template(data: RenderCVDataModel, output_path: Optional[str] = None)
# load the template:
template = environment.get_template(f"{theme}.tex.j2")
cv: CurriculumVitae = data.cv
design: Design = data.design
theme_options: ClassicThemeOptions = data.design.options
output_latex_file = template.render(
cv=data.cv,
design=data.design,
theme_options=data.design.options,
cv=cv,
design=design,
theme_options=theme_options,
today=get_today(),
)
@ -473,7 +476,7 @@ def run_latex(latex_file_path: str) -> str:
)
run()
run() # run twice for cross-references
run() # run twice for cross-references
# check if the PDF file is generated:
if not os.path.exists(output_file_path):

View File

@ -84,11 +84,16 @@
\newcolumntype{R}[1]{
>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}p{#1}
} % right-aligned fixed width column type
((* if theme_options.text_alignment == "justified" *))
\newcolumntype{K}[1]{
>{\let\newline\\\arraybackslash\hspace{0pt}}X
} % left-aligned (but justified) flexible width column type
} % 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
\newenvironment{highlights}{
\begin{itemize}[
topsep=0pt,
@ -132,7 +137,10 @@
<<header(name=cv.name, connections=cv.connections)|indent(4)>>
((* if cv.summary is not none *))
\section{Summary}
{
((* if theme_options.text_alignment == "left-aligned" *))
\raggedright
((* endif *))
\setlength{\leftskip}{<<theme_options.margins.entry_area.left_and_right>>}
\setlength{\rightskip}{<<theme_options.margins.entry_area.left_and_right>>}
@ -140,6 +148,7 @@
\setlength{\leftskip}{0cm}
\setlength{\rightskip}{0cm}
}
((* endif *))
\centering

View File

@ -94,7 +94,7 @@
((* endmacro *))
((* macro one_line(name, details, markdown_url=none, link_text=none) *))
\begingroup\raggedright
\begingroup((* if theme_options.text_alignment == "left-aligned" *))\raggedright((* endif *))
\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>>