moderncv 中的垂直对齐

moderncv 中的垂直对齐

我正在用 moderncv 撰写完整的求职申请。

我不想对这封信使用其他类别,因为我不能在那里使用 moderncv 标题的花式标题。

对于这封信,我需要知道如何将纯文本以厘米或毫米为单位从页面顶部对齐。“页面顶部”是指纸张的实际开头,而不是几何边框或类似的东西。

详情见图片:

在此处输入图片描述

感谢帮助

编辑 编辑 编辑

由于 boobyandbobs 无法理解我的意思,因此我稍微说明了一下:

首先你需要知道,我是德国人。

德国有邮政邮件标准

该标准要求如下规范,例如:

  • 创作者的联系方式必须显示在页面左对齐处,距页面顶部 1.5 厘米处
  • 信件的创作日期和地点必须右对齐,距顶部 2.2 厘米

等等。

请参阅此图片以了解清晰度:

在此处输入图片描述

编辑 编辑 编辑编号 2

抱歉,但这让我抓狂

参见 MWE:

\documentclass[12pt, a4paper]{moderncv}
\usepackage[ngerman]{babel}   
\usepackage[utf8]{inputenc}  
\usepackage[left=2.5cm, right=2.0cm, top=1.0cm, bottom=1.0cm]{geometry}  
\usepackage{fontawesome}  
\moderncvtheme[blue]{classic}
\name{{\scshape\Huge My}}{{\scshape Name}}
\address{My street}{12345 There}
\phone[handy]{\faMobile\hspace{2pt}0173\,1111111}
\usepackage{lipsum}
\begin{document}
\makecvtitle
\vspace{1cm}
\color{red}{!This has to be 2.2 centimeter from actual beginning of paper!\color{black}\\

\color{blue}{!This block\\has to be 3.4 centimeter\\from actual beginning of paper!\color{black}\\

\flushright \color{red}{This must be 4.3 centimeter from the top of the paper\color{black}\\
\flushleft
\lipsum[1-3]
\end{document}

MWE 看起来像:

在此处输入图片描述

答案1

这是我的第一次尝试。正如评论中指出的那样,这不是最佳解决方案,但也许可以有所帮助。线条和边距只是使用\usepackage{showframe}\showgrid参考@esdd)查看尺寸,并可以将其删除。

1. 将内容绝对定位在页面上:使用辅助宏\AtTextUpperLeft\AtPageUpperLeft(参见)eso-pic)以便更轻松地在页面上定位。然后移开\AtTextUpperLeft一些水平(\hspace*{<cm>})和垂直(\raisebox{<cm>}{})空间。为了获得负间距,我曾经\hspace{0pt-\widthof{<text>}获得右对齐文本。

2.给定文本的长度:calc包用于获取给定文本的宽度作为长度。

我使用了以下代码部分:

在此处输入图片描述

梅威瑟:

\documentclass[12pt, a4paper]{moderncv}
\usepackage[ngerman]{babel}   
\usepackage[utf8]{inputenc}  
\usepackage[left=2.5cm, right=2.0cm, top=1.0cm, bottom=1.0cm]{geometry}  
\usepackage{fontawesome}  
\moderncvtheme[blue]{classic}
\name{{\scshape\Huge My}}{{\scshape Name}}
\address{My street}{12345 There}
\phone[handy]{\faMobile\hspace{2pt}0173\,1111111}
\usepackage{lipsum,xcolor}
\usepackage{showframe}
\usepackage{eso-pic}

\usepackage{calc}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% code of @https://tex.stackexchange.com/a/99242/124842
\makeatletter
\def\@hspace#1{\begingroup\setlength\dimen@{#1}\hskip\dimen@\endgroup}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{tikz}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \showgrid with help of  @https://tex.stackexchange.com/a/229850/124842
\newcommand{\showgrid}{%
  \AddToShipoutPictureFG*{%
    \begin{tikzpicture}[overlay,remember picture,
        thin,nodes={font=\fontsize{1}{2}\selectfont},
        yshift=\paperheight% origin is in the upper left corner
        ]
      \draw[gray!25,step=1cm](current page.south west)grid(current page.north east);
      \draw[blue!30!gray,step=10cm](current page.south west) grid(current page.north east);
      \pgfmathtruncatemacro\xmaxstep{\paperwidth/1cm}% calculate needed steps in x direction
      \pgfmathtruncatemacro\ymaxstep{\paperheight/1cm}% calculate needed steps in y direction
      \foreach \step in {0,1,...,\xmaxstep}
        \node [anchor=north] at ([xshift=\step cm]current page.north west) {\step};
      \foreach \step in {0,1,...,\ymaxstep}
        \node [anchor=west] at ([yshift=-\step cm]current page.north west) {\step};
    \end{tikzpicture}%
  }%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\AddToShipoutPictureBG*{%

%\AtPageUpperLeft{%
%\hspace*{2.5cm}\raisebox{-2.2cm}{%
  \AtTextUpperLeft{%
  \hspace*{0cm}\hspace*{\textwidth}\hspace{0pt-\widthof{Is this okay? ...4.3 centimeter from the top of the paper}}\hspace{2cm-0.81cm}\raisebox{-4.3cm}{%
  \color{red}Is this okay? ...4.3 centimeter from the top of the paper
  }}

\AtTextUpperLeft{%
\hspace*{0cm}\raisebox{-2.2cm}{%
\color{blue}Is this okay? ...2.2 centimeter from the top of the paper
}
}

\AtTextUpperLeft{%
\hspace*{0cm}\raisebox{-3.4cm}{%
\color{blue}
Is this okay? ...3.4 centimeter from the top of the paper ... (single line)
}
}%

\AtTextUpperLeft{%
\hspace*{0cm}\raisebox{-3.87cm}{%
\color{green}
\begin{minipage}{30em}
 Is this okay? ...3.4 centimeter from the top of the paper \\
next line \\
... and ...
\end{minipage}
}}
}%

\showgrid
\makecvtitle
\vspace{1cm}
\flushleft
\lipsum[1-3]
\end{document}

答案2

感谢 Bobbyanbob,但现在删除的评论更适合它。提到的德语文档(http://archiv.dante.de/DTK/PDF/komoedie_2011_1.pdf) 在第 30-40 页给了我一个很好的解决方案。

相关内容