我想\mycventry
根据此处接受的答案的解决方案定义自己的 cv-entry线。
这导致了这个代码:
%% start of file `template.tex'.
%% Copyright 2006-2015 Xavier Danaux ([email protected]).
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License version 1.3c,
% available at http://www.latex-project.org/lppl/.
\documentclass[11pt,a4paper,sans]{moderncv} % possible options include font size ('10pt', '11pt' and '12pt'), paper size ('a4paper', 'letterpaper', 'a5paper', 'legalpaper', 'executivepaper' and 'landscape') and font family ('sans' and 'roman')
\usepackage{tabularx}
% moderncv themes
\moderncvstyle{classic} % style options are 'casual' (default), 'classic', 'banking', 'oldstyle' and 'fancy'
\moderncvcolor{blue} % color options 'black', 'blue' (default), 'burgundy', 'green', 'grey', 'orange', 'purple' and 'red'
%\renewcommand{\familydefault}{\sfdefault} % to set the default font; use '\sfdefault' for the default sans serif font, '\rmdefault' for the default roman one, or any tex font name
%\nopagenumbers{} % uncomment to suppress automatic page numbering for CVs longer than one page
\newcommand*{\mycventry}[7][.25em]{%
\cvitem[#1]{#2}{%
{\bfseries#3 \newline}%
% \ifthenelse{\equal{#4}{}}{}{\newline {#4}}%sth to describe
% \ifthenelse{\equal{#5}{}}{}{\hspace{1cm} #5}%description
\begin{tabularx}{\textwidth}{l X}
#4 & #5
\end{tabularx}
\ifthenelse{\equal{#6}{}}{}{\newline #6}%
\strut%
\ifx&%
\else{\newline{}\begin{minipage}[t]{\linewidth}\small#7\end{minipage}}\fi}}
% character encoding
%\usepackage[utf8]{inputenc} % if you are not using xelatex ou lualatex, replace by the encoding you are using
%\usepackage{CJKutf8} % if you need to use CJK to typeset your resume in Chinese, Japanese or Korean
% adjust the page margins
\usepackage[scale=0.75]{geometry}
%\setlength{\hintscolumnwidth}{3cm} % if you want to change the width of the column with the dates
%\setlength{\makecvheadnamewidth}{10cm} % for the 'classic' style, if you want to force the width allocated to your name and avoid line breaks. be careful though, the length is normally calculated to avoid any overlap with your personal info; use this at your own typographical risks...
% personal data
\name{John}{Doe}
\title{Resumé title} % optional, remove / comment the line if not wanted
\address{street and number}{postcode city}{country}% optional, remove / comment the line if not wanted; the "postcode city" and "country" arguments can be omitted or provided empty
\phone[mobile]{+1~(234)~567~890} % optional, remove / comment the line if not wanted; the optional "type" of the phone can be "mobile" (default), "fixed" or "fax"
\phone[fixed]{+2~(345)~678~901}
\phone[fax]{+3~(456)~789~012}
\email{[email protected]} % optional, remove / comment the line if not wanted
\homepage{www.johndoe.com} % optional, remove / comment the line if not wanted
\social[linkedin]{john.doe} % optional, remove / comment the line if not wanted
\social[xing]{john\_doe} % optional, remove / comment the line if not wanted
\social[twitter]{jdoe} % optional, remove / comment the line if not wanted
\social[github]{jdoe} % optional, remove / comment the line if not wanted
\social[gitlab]{jdoe} % optional, remove / comment the line if not wanted
\social[skype]{jdoe} % optional, remove / comment the line if not wanted
\extrainfo{additional information} % optional, remove / comment the line if not wanted
\photo[64pt][0.4pt]{picture} % optional, remove / comment the line if not wanted; '64pt' is the height the picture must be resized to, 0.4pt is the thickness of the frame around it (put it to 0pt for no frame) and 'picture' is the name of the picture file
\quote{Some quote} % optional, remove / comment the line if not wanted
% bibliography adjustements (only useful if you make citations in your resume, or print a list of publications using BibTeX)
% to show numerical labels in the bibliography (default is to show no labels)
%\makeatletter\renewcommand*{\bibliographyitemlabel}{\@biblabel{\arabic{enumiv}}}\makeatother
\renewcommand*{\bibliographyitemlabel}{[\arabic{enumiv}]}
% to redefine the bibliography heading string ("Publications")
%\renewcommand{\refname}{Articles}
% bibliography with mutiple entries
%\usepackage{multibib}
%\newcites{book,misc}{{Books},{Others}}
%----------------------------------------------------------------------------------
% content
%----------------------------------------------------------------------------------
\begin{document}
%\begin{CJK*}{UTF8}{gbsn} % to typeset your resume in Chinese using CJK
%----- resume ---------------------------------------------------------
\makecvtitle
%\moderncvstyle{fancy}
\section{Education}
\mycventry{year--year}{Degree}{sth-todescribe:}{Description starts here. This text needs automatic linebreak due to it's length. This text needs automatic linebreak due to it's length. This text needs automatic linebreak due to it's length. But it should stop before the end of the page.}{\textit{Grade}}{Description} % arguments 3 to 6 can be left empty
\end{document}
%% end of file `template.tex'.
我的问题是:
sth-to-describe:
我怎样才能增加和描述之间的距离?不知道第二列(说明)的确切宽度。如果
sth-to-describe
更改,第二列的宽度也会更改。如何在不知道列的确切宽度的情况下实现自动换行,以便说明准确地在行末而不是在页面末尾换行?
答案1
只需更改\textwidth
为\linewidth
,因为的布局moderncv
使用两列布局:第一列用于日期和部分标题中的规则,第二列有自己的\linewidth
(!)用于描述...
使用以下 MWE
\documentclass[11pt,a4paper,sans]{moderncv}
% moderncv themes
\moderncvstyle{classic}
\moderncvcolor{blue}
%\renewcommand{\familydefault}{\sfdefault}
%\nopagenumbers{}
\usepackage{tabularx}
\newcommand*{\mycventry}[7][.25em]{%
\cvitem[#1]{#2}{%
{\bfseries#3 \newline}%
% \ifthenelse{\equal{#4}{}}{}{\newline {#4}}%sth to describe
% \ifthenelse{\equal{#5}{}}{}{\hspace{1cm} #5}%description
\begin{tabularx}{\linewidth}{l X} % <===========================
#4 & #5
\end{tabularx}
\ifthenelse{\equal{#6}{}}{}{\newline #6}%
\strut%
\ifx&%
\else{\newline{}\begin{minipage}[t]{\linewidth}\small#7\end{minipage}}\fi%
}%
}
\usepackage[utf8]{inputenc}
% adjust the page margins
\usepackage[%
scale=0.75,
showframe, % <==================== to visualize typing area and margins
]{geometry}
%\setlength{\hintscolumnwidth}{3cm}
%\setlength{\makecvheadnamewidth}{10cm}
% personal data
\name{John}{Doe}
\title{Resumé title}
\address{street and number}{postcode city}{country}% optional, remove / comment the line if not wanted; the "postcode city" and "country" arguments can be omitted or provided empty
\phone[mobile]{+1~(234)~567~890} % optional, remove / comment the line if not wanted; the optional "type" of the phone can be "mobile" (default), "fixed" or "fax"
\phone[fixed]{+2~(345)~678~901}
\phone[fax]{+3~(456)~789~012}
\email{[email protected]} % optional, remove / comment the line if not wanted
\homepage{www.johndoe.com} % optional, remove / comment the line if not wanted
\social[linkedin]{john.doe} % optional, remove / comment the line if not wanted
\social[xing]{john\_doe} % optional, remove / comment the line if not wanted
\social[twitter]{jdoe} % optional, remove / comment the line if not wanted
\social[github]{jdoe} % optional, remove / comment the line if not wanted
\social[gitlab]{jdoe} % optional, remove / comment the line if not wanted
\social[skype]{jdoe} % optional, remove / comment the line if not wanted
\extrainfo{additional information} % optional, remove / comment the line if not wanted
\photo[64pt][0.4pt]{example-image}
\quote{Some quote}
\begin{document}
\makecvtitle
%\moderncvstyle{fancy}
\section{Education}
\mycventry%
{year--year-2}%
{Degree-3}%
{sth-todescribe:-4}%
{Description starts here. This text needs automatic linebreak due to it's length. This text needs automatic linebreak due to it's length. This text needs automatic linebreak due to it's length. But it should stop before the end of the page.-5}%
{\textit{Grade}-6}%
{Description-7} % arguments 3 to 6 can be left empty
\end{document}
你得到了想要的结果:
为了获得更好的外观,在l
和X
列之间添加一些空间,例如:
\begin{tabularx}{\linewidth}{l p{1em} X} % <====================
#4 & & #5 % <===============================================
\end{tabularx}
结果如下: