我想写一个\tllabelcventry
没有描述行的,并尝试定义一个新命令\tllabelcventrywithoutdescription
。我查看了moderncv
和moderntimeline
命令定义来实现这一点,但我陷入困境,因为我不太明白在哪里可以硬编码这样的更改。
我想省略描述行的原因是,如果我不在中提供描述\tllabelcventry
,则每个条目下面都会出现一个令人讨厌的空行。
有人可以帮我从这里出去吗?
最小示例:
\documentclass[ngerman,11pt,a4paper,sans]{moderncv}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\makeatletter
\moderncvstyle{classic}
\moderncvcolor{blue}
\usepackage[scale=0.8]{geometry}
\setlength{\hintscolumnwidth}{3cm}
\usepackage{moderntimeline}
\tlmaxdates{2007}{2018}
\name{name}{surname}
\title{how to omit the description line?{}}
\newcommand{\tllabelcventrywithoutdescription}[9][color1]{%
\pgfmathsetmacro\tl@endyear{ifthenelse(#3==0,\tl@lastyear,#3)}
\pgfmathsetmacro\tl@startfraction{(#2-\tl@firstyear)/(\tl@lastyear- \tl@firstyear)}%
\pgfmathsetmacro\tl@endfraction{(\tl@endyear- \tl@firstyear)/(\tl@lastyear-\tl@firstyear)}%
\cventry{\tikz[baseline=0pt]{
\fill [\tl@runningcolor] (0,0)
rectangle (\hintscolumnwidth,\tl@runningwidth);
\useasboundingbox (0,-1.5ex)
rectangle (\hintscolumnwidth,1ex);
\fill [#1] (0,0)
++(\tl@startfraction*\hintscolumnwidth,0pt)
node [tl@startyear] {#4}
rectangle (\tl@endfraction*\hintscolumnwidth,\tl@width-1pt);
\pgfmathsetlength{\pgf@xa}{#3} \ifdim\pgf@xa=0pt
\shade [left color=#1] (\tl@startfraction*\hintscolumnwidth,0)
rectangle (\tl@endfraction*\hintscolumnwidth,\tl@width);
\else
\fill [#1] (\tl@startfraction*\hintscolumnwidth,0)
rectangle (\tl@endfraction*\hintscolumnwidth,\tl@width);
\fi
}
}
{#5}{#6}{#7}{#8}{#9}%
}
\usepackage{babel}
\usepackage[style=authoryear]{biblatex}
\begin{document}
\makecvtitle
\section{Section}
\tllabelcventrywithoutdescription{2008/10}{2009/9}{2008/10 -- 2009/9}{\textbf{Grade}} {Institution}{City}{}{}
\tllabelcventrywithoutdescription{2008/10}{2009/9}{2008/10 -- 2009/9}{\textbf{Grade}} {Institution}{City}{}{}
\tllabelcventrywithoutdescription{2008/10}{2009/9}{2008/10 -- 2009/9}{\textbf{Grade}} {Institution}{City}{}{Description}
\tllabelcventrywithoutdescription{2008/10}{2009/9}{2008/10 -- 2009/9}{\textbf{Grade}} {Institution}{City}{}{Description}
\end{document}
我尝试通过删除 来删除描述{#9}
,代码编译通过,但空行仍然存在。对于训练有素的人来说,这种改变应该很容易,但不幸的是我没有这种能力。
亲切的问候,
snapdeb
答案1
您正在使用命令的定义,\tllabelcventry
我不知道它来自哪里......
中的原始定义moderntimeline.sty
是
\newcommand{\tllabelcventry}[9][color1]{%
\tl@formatendyear{#3}
\tl@formatstartyear{#2}
\cventry{\tikz[baseline=0pt]{
\fill [\tl@runningcolor] (0,0)
rectangle (\hintscolumnwidth,\tl@runningwidth);
\useasboundingbox (0,-1.5ex)
rectangle (\hintscolumnwidth,1ex);
\fill [#1] (0,0)
++(\tl@startfraction*\hintscolumnwidth,0pt)
node [tl@startyear] {#4}
rectangle (\tl@endfraction*\hintscolumnwidth,\tl@width-1pt) ;
\ifissince
\newdimen\fullcolorwidth
\pgfmathsetlength\fullcolorwidth{\tl@startfraction*(1+(1-\tl@startfraction)*\tl@nsfrac)*\hintscolumnwidth}
\shade [left color=#1,right color=#1]
(\tl@startfraction*\hintscolumnwidth,0)
rectangle (\fullcolorwidth,\tl@width);
\shade [left color=#1] (\fullcolorwidth,0)
rectangle (\tl@endfraction*\hintscolumnwidth,\tl@width);
\else
\fill [#1] (\tl@startfraction*\hintscolumnwidth,0)
rectangle (\tl@endfraction*\hintscolumnwidth,\tl@width);
\fi
}
}
{#5}{#6}{#7}{#8}{#9}%
}
您可以更改命令\cventry
以\cventry[-\baselineskip]
删除空行......
使用以下 MWE
\documentclass[ngerman,11pt,a4paper,sans]{moderncv}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\moderncvstyle{classic}
\moderncvcolor{blue}
\usepackage[scale=0.8]{geometry}
\setlength{\hintscolumnwidth}{3cm}
\usepackage{moderntimeline}
\tlmaxdates{2007}{2018}
\name{name}{surname}
\title{how to omit the description line?{}}
\makeatletter
\newcommand{\tllabelcventrywithoutdescription}[9][color1]{%
\tl@formatendyear{#3}
\tl@formatstartyear{#2}
\cventry[-\baselineskip]{\tikz[baseline=0pt]{ % <======================
\fill [\tl@runningcolor] (0,0)
rectangle (\hintscolumnwidth,\tl@runningwidth);
\useasboundingbox (0,-1.5ex)
rectangle (\hintscolumnwidth,1ex);
\fill [#1] (0,0)
++(\tl@startfraction*\hintscolumnwidth,0pt)
node [tl@startyear] {#4}
rectangle (\tl@endfraction*\hintscolumnwidth,\tl@width-1pt) ;
\ifissince
\newdimen\fullcolorwidth
\pgfmathsetlength\fullcolorwidth{\tl@startfraction*(1+(1-\tl@startfraction)*\tl@nsfrac)*\hintscolumnwidth}
\shade [left color=#1,right color=#1]
(\tl@startfraction*\hintscolumnwidth,0)
rectangle (\fullcolorwidth,\tl@width);
\shade [left color=#1] (\fullcolorwidth,0)
rectangle (\tl@endfraction*\hintscolumnwidth,\tl@width);
\else
\fill [#1] (\tl@startfraction*\hintscolumnwidth,0)
rectangle (\tl@endfraction*\hintscolumnwidth,\tl@width);
\fi
}
}
{#5}{#6}{#7}{#8}{#9}%
}
\makeatother
\usepackage{csquotes} % <===============================================
\usepackage{babel}
\usepackage[style=authoryear]{biblatex}
\begin{document}
\makecvtitle
\section{Section}
\tllabelcventrywithoutdescription{2008/10}{2009/9}{2008/10 -- 2009/9}{\textbf{Grade}} {Institution}{City}{}{}
\tllabelcventrywithoutdescription{2008/10}{2009/9}{2008/10 -- 2009/9}{\textbf{Grade}} {Institution}{City}{}{}
\tllabelcventry{2008/10}{2009/9}{2008/10 -- 2009/9}{\textbf{Grade}} {Institution}{City}{}{Description}
\tllabelcventry{2008/10}{2009/9}{2008/10 -- 2009/9}{\textbf{Grade}} {Institution}{City}{}{Description}
\end{document}
您可以使用这两个命令\tllabelcventry
和\tllabelcventrywithoutdescription
: