简历的时间跨度格式

简历的时间跨度格式

我想将月份添加到现代简历为了不占用太多空间,同时仍然有一个漂亮的解决方案,我想做以下事情:
年 - 年月
-

  • 两个日期之间只有一个垂直居中的破折号,
  • 月份位于年份的中心
  • 如果需要,年份会拉伸至单元格宽度
  • 占用空间小,没有边距

我已经做了一些实验,但无法获得正确的边距和拉伸。

\documentclass{article}
\usepackage{tabu}
\usepackage[english]{babel}
\usepackage{datetime}

\newcommand* \hintscolumnwidth {0.2\textwidth} % best: 0.175\textwidth

\newcommand \testBb [4]{%
     \begin{tabu} to \hintscolumnwidth {|@{} X[c m] @{--} X[c m] @{}|}
     \hline \linespread{0}#2\newline \tiny #1&\linespread{0}#4 \newline\tiny #3 \\ \hline
     \end{tabu}}

\newcommand \testB [4]{%
     \begin{tabu} to \hintscolumnwidth {|@{} X[c m] @{}|@{} X[c m] @{}|}
     \hline \linespread{0}#2\newline \tiny #1&\linespread{0}#4 \newline\tiny #3  \\\hline
     \end{tabu}}

\newcommand \testA [4]{%
    \begin{tabu} to \hintscolumnwidth {@{}|X[-1,m,c]|@{--}X[-1,m, c]|@{}}  %spread 2cm
        \hline      {#2 } & #4 \\ \tiny #1 & \tiny #3\\ \hline 
    \end{tabu}}

\def \dateA [#1.#2-#3.#4]{ \testA{\monthname[#1]} {#2}  {\monthname[#3]}  {#4} }
\def \dateB [#1.#2-#3.#4]{ \testB{\monthname[#1]} {#2}  {\monthname[#3]}  {#4} }
\def \dateBb [#1.#2-#3.#4]{ \testBb{\monthname[#1]} {#2}  {\monthname[#3]}  {#4} }

\begin{document}%
\ \\
\dateA[09.2008-09.2012]\ \\
\dateB[09.2008-09.2012]\ \\
\dateBb[09.2008-09.2012]\ \\
2008--2012
\end{document}

产生以下结果:
结果

欢迎任何关于如何使其更加美观的建议。

更新: 我退后一步,只使用方框就解决了这个问题。我的问题是,如果想在现有的禁忌单元格中使用它们,我必须用 \newline 替换 \。这会弄乱行距,例如

\documentclass{article}
\usepackage{tabu,xcolor}
\usepackage[ngerman]{babel}
\usepackage{datetime}

\newcommand* \datumsZellenBreite {11mm}
\newcommand* \datumsZifferMonatsAbstand{-0.8mm}
\newcommand \zeitspanneA[4]{%same as B, but uses \newline instead of \\ for linebreak
    {\parbox{\datumsZellenBreite}{\centering{#2%
    %\\%
    \newline
    \vspace{-2.8mm}\tiny #1}}}\hspace{\datumsZifferMonatsAbstand}{\raisebox{0.4mm}{\color{blue}$\rightarrow$}}\hspace{\datumsZifferMonatsAbstand}{\parbox{\datumsZellenBreite}{\centering{#4%
    %\\%
    \newline
    \vspace{-2.8mm}\tiny #3}}}
}
\def \zeitA [#1.#2-#3.#4]{ \zeitspanneA{\monthname[#1]} {#2}  {\monthname[#3]}  {#4} }

\newcommand \zeitspanneB[4]{
    {{\parbox{\datumsZellenBreite}{\centering{#2\\\vspace{-2.8mm}\tiny #1}}}\hspace{\datumsZifferMonatsAbstand}{\raisebox{0.4mm}{\color{blue}$\rightarrow$}}\hspace{\datumsZifferMonatsAbstand}{\parbox{\datumsZellenBreite}{\centering{#4\\\vspace{-2.8mm}\tiny #3}}}}
}
\def \zeitB [#1.#2-#3.#4]{ \zeitspanneB{\monthname[#1]} {#2}  {\monthname[#3]}  {#4} }

\begin{document}%
A should look like B, so it can be used inside tabu.\\ \ \\
\zeitB[09.2008-09.2012]\ B\\ \\
\zeitA[09.2008-09.2012]\ A\\ \\

\begin{tabu}{XX}
a & \zeitA[09.2008-09.2012] %can't use B here
\end{tabu}

\end{document}

结果是 box示例

更新2: 我现在离我想要的已经很近了。实际上,\baselineskip=-valA\newline\par\vspace{-valA}要得到正确的年月间隔对我来说就像巫术一样,但我应该牺牲一只山羊来找到它。唯一不想要的是A 并不像数字那样从同一基线开始

\documentclass{article}
\usepackage{tabu,xcolor}
\usepackage[ngerman]{babel}
\usepackage{datetime}

\setlength\fboxsep{0pt}
\newcommand* \datumsZellenBreite {10.5mm}
\newcommand* \datumsZifferMonatsAbstand{-2.8mm}
\newcommand \zeitspanne[4]{%same as B, but uses \newline instead of \\ for linebreak
    {\parbox{\datumsZellenBreite}{\centering{#2\baselineskip=\datumsZifferMonatsAbstand\newline\par\vspace{\datumsZifferMonatsAbstand}\tiny{\strut#1}}}}\hspace{-0.6mm}{\raisebox{0.35mm}{\color{blue}--}}\hspace{-0.2mm}%
    {\parbox{\datumsZellenBreite}{\centering{#4\baselineskip=\datumsZifferMonatsAbstand\newline\par\vspace{\datumsZifferMonatsAbstand}\tiny{\strut#3}}}}%
}
\def \zeit[#1.#2-#3.#4]{\zeitspanne{\monthname[#1]}{#2}{\monthname[#3]}{#4}}

\begin{document}%
\begin{tabu}{@{}X[-1]@{}|X@{}}
\hline%
A & \zeit[09.2008-09.2012]
\\\hline
\end{tabu}
\end{document}

生成:

Datum3

有什么想法可以修复此问题吗?

答案1

也许像这样?我用过tabularx而不是tabu。 的垂直对齐方式tabularx设置为[t],并使用\firsthline(来自包):array

\documentclass{article}
\usepackage[english]{babel}
\usepackage{array}
\usepackage{tabularx}
\usepackage{datetime}

\newcolumntype{Y}{>{\small\centering\arraybackslash}X}

\newcommand*\hintscolumnwidth{0.2\textwidth} % best: 0.175\textwidth

\def\dateS[#1.#2-#3.#4]{\testS{\monthname[#1]}{#2}{\monthname[#3]}{#4}}

\newcommand\testS[4]{%
{\renewcommand\arraystretch{0.8}
\begin{tabularx}{\hintscolumnwidth}[t]{|@{}Y@{}c@{}Y@{}|}
\firsthline
#2 &\multicolumn{1}{@{}c@{}}{--} & #4 \\[-1ex]
\tiny#1 && \tiny#3 \\
\hline
\end{tabularx}}}

\begin{document}%

\dateS[09.2008-12.2012] Some text\par
\dateS[01.1997-09.2012] Some text\par
\dateS[09.2000-09.2012] Some text

\end{document}

在此处输入图片描述

使用盒子(在本例中为minipages 和\parboxes)就不需要任何额外的包:

\documentclass{article}
\usepackage[english]{babel}
\usepackage{datetime}

\newlength\mylen
\settowidth\mylen{--}
\newlength\hintscolumnwidth
\setlength\hintscolumnwidth{0.2\textwidth} % best: 0.175\textwidth

\def\dateS[#1.#2-#3.#4]{\testS{\monthname[#1]}{#2}{\monthname[#3]}{#4}}

\newcommand\testS[4]{%
{\setlength\fboxsep{0pt}%
\fbox{\begin{minipage}[t]{\hintscolumnwidth}
\parbox[t]{0.5\hintscolumnwidth}{\centering%
\raggedright%
\makebox[0pt][l]{\hspace*{\dimexpr0.5\hintscolumnwidth-2\mylen\relax}--}%
\centering#2\\ \tiny#1
}%
\parbox[t]{0.5\hintscolumnwidth}{\centering%
#4\\ \tiny#3
}%
\end{minipage}}}}

\begin{document}%

\dateS[09.2008-12.2012] Some text\par
\dateS[01.1997-09.2012] Some text\par
\dateS[09.2000-09.2012] Some text

\end{document}

在此处输入图片描述

答案2

甘露醇来自#latex 建议另一种使用蒂克兹

\documentclass{article}
\usepackage{tabu,xcolor}
\usepackage[ngerman]{babel}
\usepackage{datetime}
\usepackage{tikz} 

\setlength\fboxsep{0pt}
\newcommand* \datumsZellenBreite {10.5mm}
\newcommand* \datumsZifferMonatsAbstand{-2.8mm}
\newcommand \zeitspanne[4]{
        {\parbox{\datumsZellenBreite}{\centering{#2\baselineskip=\datumsZifferMonatsAbstand\newline\par\vspace{\datumsZifferMonatsAbstand}\tiny{\strut#1}}}}\hspace{-0.6mm}{\raisebox{0.35mm}{\color{blue}--}}\hspace{-0.2mm}%
        {\parbox{\datumsZellenBreite}{\centering{#4\baselineskip=\datumsZifferMonatsAbstand\newline\par\vspace{\datumsZifferMonatsAbstand}\tiny{\strut#3}}}}%
}
\def \zeit[#1.#2-#3.#4]{\zeitspanne{\monthname[#1]}{\ #2}{\monthname[#3]}{\ #4}}

\begin{document}%

\begin{tikzpicture}
  \useasboundingbox (0cm,0cm) rectangle (\textwidth,1cm);
  \coordinate (A) at (0,0);
  \coordinate (B) at (\textwidth,0);
  \coordinate (I) at (0.5,0);
  \coordinate (J) at (0.5,1);
  \coordinate (Zeitpos) at (1,0.5);
  \coordinate (C) at (0,1);
  \coordinate (D) at (\textwidth,1);

  \draw  (0,0.6) node {A};
  \draw (A)--(B);
  \draw (C)--(D);
  \draw (Zeitpos) node [right] {\zeit[09.2008-03.2012]};
  \draw (I)--(J);      
\end{tikzpicture}

\vspace{2cm}

\begin{tabu}{@{}X[-1]@{}|X@{}}
\hline%
A & \zeit[09.2008-03.2012]
\\\hline
\end{tabu}
\end{document}

相关内容