![在静态页面上定义文本块](https://linux22.com/image/441024/%E5%9C%A8%E9%9D%99%E6%80%81%E9%A1%B5%E9%9D%A2%E4%B8%8A%E5%AE%9A%E4%B9%89%E6%96%87%E6%9C%AC%E5%9D%97.png)
我正在寻找一种使用 latex 编写自己的静态页面的方法。为此,我混合了环境和命令。现在我有一个非常简单的标题页,但效果不太好。
它看起来应该是这样的:
- LOGO -
DA TITLE
LEFT DATE RIGHT AUTHOR
标题较大且居中,日期和作者较小但左/右浮动。
我可以定位这些块,但有几个问题表明我使用了错误的方法。
例如,如果标题太长则不会换行,并且左侧和右侧均不会浮动。
\newcommand{\MyTitlePage}{
\begin{tikzpicture}[overlay, remember picture]%
\node[anchor=north, text=black, font=\small, inner ysep=0.5cm, inner xsep=2cm] at (current page.north) {\includegraphics[width=12cm]{logo.png}};
\node[anchor=north, text=black, font=\small, inner ysep=0.5cm, inner xsep=2cm] at ($(current page.center) + (0cm,-4cm)$) {\fontsize{24}{28}\MontserratBold \centering{\varDocumentTitle }};
\node[anchor=north, text=black, font=\small, inner ysep=0.5cm, inner xsep=2cm] at ($(current page.west) + (+3cm,-8cm)$) {\fontsize{14}{18}\MontserratBold \raggedleft \varDate };
\node[anchor=north, text=black, font=\small, inner ysep=0.5cm, inner xsep=2cm] at ($(current page.east) + (-3cm,-8cm)$) {\fontsize{14}{18}\MontserratBold \raggedright{\varAuthor} };
\end{tikzpicture}
\pagebreak
}
答案1
封面
第二页
\documentclass[border=10pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\newcommand{\MyTitlePage}{
\thispagestyle{empty}
\begin{tikzpicture}[overlay, remember picture]%
\node[]
at ($(current page.north)+(0cm, -4cm)$) {\includegraphics[width=6cm]{example-image}};
\node[]
at ($(current page.center) + (0cm,0cm)$) {\Huge Title };
\node[]
at ($(current page.west) + (+3cm,-8cm)$) {\Large Date };
\node[]
at ($(current page.east) + (-3cm,-8cm)$) {\Large Author};
\end{tikzpicture}
\newpage
}
\MyTitlePage
Dear
\end{document}
用于划分长标题
\documentclass[border=10pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\newcommand{\MyTitlePage}{
\thispagestyle{empty}
\begin{tikzpicture}[overlay, remember picture]%
\node[]
at ($(current page.north)+(0cm, -4cm)$) {\includegraphics[width=6cm]{example-image}};
\node[text width=4cm, align=center]
at ($(current page.center) + (0cm,0cm)$) {\Huge {A Very Long Title} };
\node[]
at ($(current page.west) + (+3cm,-8cm)$) {\Large Date };
\node[]
at ($(current page.east) + (-3cm,-8cm)$) {\Large Author};
\end{tikzpicture}
\newpage
}
\MyTitlePage
Dear
\end{document}