我经常需要为简历和求职信生成单独的 PDF 文件。在我的系统 (Mac) 上,模板文件位于:
/usr/local/texlive/2016/texmf-dist/doc/latex/moderncv/examples/template.tex
我可以在注释掉一半文件后运行 LuaLaTeX/XeLaTeX 来生成两个单独的文件。例如:
\documentclass[11pt,a4paper,sans]{moderncv}
\name{John}{Doe}
\begin{document}
%----------------cv----------------
\makecvtitle
\section{Education}
\cventry{year--year}{Degree}{Institution}{}{}{}
% \clearpage
% %----------------letter----------------
% % recipient data
% \recipient{Joe}{Company}
% \makelettertitle
% % letter
% \makeletterclosing
\end{document}
但是这样很笨拙,而且容易出错。有没有直接的方法生成两个文件。
请注意,使用 PDF 拆分工具拆分文件(pdftk,或者在 OS X 上为预览)会留下错误的页码,并导致 PDF 文件过大。
答案1
一种可能性是定义新的布尔变量并在 TeX 文件中使用它们。
添加以下代码
\usepackage{ifthen} % <===========================================
\newboolean{CV}
\setboolean{CV}{false} % <===========================================
\newboolean{Letter}
\setboolean{Letter}{true} % <===========================================
\begin{document}
\ifthenelse{\boolean{CV}}{% print CV
% add code here for CV
}{% print no CV
}
\ifthenelse{\boolean{Letter}}{% print Cover Letter
% add code here for letter
}{% print no Cover Letter
}
\setboolean
您可以根据需要使用命令定义true
或定义两个变量。false
使用以下可编译代码,您可以获得信件,但没有简历:
\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{classic} % classic banking
\moderncvcolor{blue}
%\nopagenumbers{}
\usepackage[utf8]{inputenc}
\usepackage[scale=0.75]{geometry}
\name{John}{Doe}
\title{Resumé title}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}
\phone[fixed]{+2~(345)~678~901}
\phone[fax]{+3~(456)~789~012}
\email{[email protected]}
\homepage{www.johndoe.com}
\social[linkedin]{john.doe}
\social[twitter]{jdoe}
\social[github]{jdoe}
\extrainfo{additional information\\information 2}
\photo[64pt][0.4pt]{example-image-a}
\quote{Some quote}
\setlength{\footskip}{66pt}
\usepackage{ifthen} % <===========================================
\newboolean{CV}
\setboolean{CV}{false} % <===========================================
\newboolean{Letter}
\setboolean{Letter}{true} % <===========================================
\begin{document}
\ifthenelse{\boolean{CV}}{% print CV
\makecvtitle
\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description} % arguments 3 to 6 can be left empty
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\section{Master thesis}
\cvitem{title}{\emph{Title}}
\cvitem{supervisors}{Supervisors}
\cvitem{description}{Short thesis abstract}
\section{Experience}
\subsection{Vocational}
\cventry{year--year}{Job title}{Employer}{City}{}{General description no longer than 1--2 lines.\newline{}%
Detailed achievements:%
\begin{itemize}%
\item Achievement 1;
\item Achievement 2, with sub-achievements:
\begin{itemize}%
\item Sub-achievement (a);
\item Sub-achievement (b), with sub-sub-achievements (don't do this!);
\begin{itemize}
\item Sub-sub-achievement i;
\item Sub-sub-achievement ii;
\item Sub-sub-achievement iii;
\end{itemize}
\item Sub-achievement (c);
\end{itemize}
\item Achievement 3.
\end{itemize}}
\cventry{year--year}{Job title}{Employer}{City}{}{Description line 1\newline{}Description line 2}
\subsection{Miscellaneous}
\cventry{year--year}{Job title}{Employer}{City}{}{Description}
\section{Languages}
\cvitemwithcomment{Language 1}{Skill level}{Comment}
\cvitemwithcomment{\textbf{Language} 2}{\textbf{Skill} level}{Comment}
\cvitemwithcomment{Language 3}{Skill level}{Comment}
\section{Computer skills}
\cvdoubleitem{category 1}{XXX, YYY, ZZZ}{category 4}{XXX, YYY, ZZZ}
\cvdoubleitem{category 2}{XXX, YYY, ZZZ}{category 5}{XXX, YYY, ZZZ}
\cvdoubleitem{category 3}{XXX, YYY, ZZZ}{category 6}{XXX, YYY, ZZZ}
\section{Interests}
\cvitem{hobby 1}{Description}
\cvitem{hobby 2}{Description}
\cvitem{hobby 3}{Description}
\section{Extra 1}
\cvlistitem{Item 1}
\cvlistitem{Item 2}
\cvlistitem{Item 3. This item is particularly long and therefore normally spans over several lines. Did you notice the indentation when the line wraps?}
\section{Extra 2}
\cvlistdoubleitem{Item 1}{Item 4}
\cvlistdoubleitem{Item 2}{Item 5\cite{book1}}
\cvlistdoubleitem{Item 3}{Item 6. Like item 3 in the single column list before, this item is particularly long to wrap over several lines.}
\section{References}
\begin{cvcolumns}
\cvcolumn{Category 1}{\begin{itemize}\item Person 1\item Person 2\item Person 3\end{itemize}}
\cvcolumn{Category 2}{Amongst others:\begin{itemize}\item Person 1, and\item Person 2\end{itemize}(more upon request)}
\cvcolumn[0.5]{All the rest \& some more}{\textit{That} person, and \textbf{those} also (all available upon request).}
\end{cvcolumns}
\nocite{*}
\bibliographystyle{plain}
\bibliography{publications} % 'publications' is the name of a BibTeX file
\clearpage
}{% print no CV
}
\ifthenelse{\boolean{Letter}}{% print Cover Letter
%----- letter ---------------------------------------------------------
% recipient data
\recipient{Company Recruitment team}{Company, Inc.\\123 somestreet\\some city}
\date{January 01, 1984}
\opening{Dear Sir or Madam,}
\closing{Yours faithfully,}
\enclosure[Attached]{curriculum vit\ae{}}
\makelettertitle
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis ullamcorper neque sit amet lectus facilisis sed luctus nisl iaculis. Vivamus at neque arcu, sed tempor quam. Curabitur pharetra tincidunt tincidunt. Morbi volutpat feugiat mauris, quis tempor neque vehicula volutpat. Duis tristique justo vel massa fermentum accumsan. Mauris ante elit, feugiat vestibulum tempor eget, eleifend ac ipsum. Donec scelerisque lobortis ipsum eu vestibulum. Pellentesque vel massa at felis accumsan rhoncus.
Suspendisse commodo, massa eu congue tincidunt, elit mauris pellentesque orci, cursus tempor odio nisl euismod augue. Aliquam adipiscing nibh ut odio sodales et pulvinar tortor laoreet. Mauris a accumsan ligula. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse vulputate sem vehicula ipsum varius nec tempus dui dapibus. Phasellus et est urna, ut auctor erat. Sed tincidunt odio id odio aliquam mattis. Donec sapien nulla, feugiat eget adipiscing sit amet, lacinia ut dolor. Phasellus tincidunt, leo a fringilla consectetur, felis diam aliquam urna, vitae aliquet lectus orci nec velit. Vivamus dapibus varius blandit.
Duis sit amet magna ante, at sodales diam. Aenean consectetur porta risus et sagittis. Ut interdum, enim varius pellentesque tincidunt, magna libero sodales tortor, ut fermentum nunc metus a ante. Vivamus odio leo, tincidunt eu luctus ut, sollicitudin sit amet metus. Nunc sed orci lectus. Ut sodales magna sed velit volutpat sit amet pulvinar diam venenatis.
Albert Einstein discovered that $e=mc^2$ in 1905.
\[ e=\lim_{n \to \infty} \left(1+\frac{1}{n}\right)^n \]
\makeletterclosing
}{% print no Cover Letter
}
\end{document}
得到的 pdf 格式如下:
因此,首先根据需要设置布尔变量,然后编译三次,复制生成的 pdf,再次更改布尔变量,再编译三次。现在您有两个 pdf 文件,一个包含简历,另一个仅包含信件...
答案2
创建一个新的布尔值(如另一个答案中所述)似乎有点过度,而且不是特别灵活。另一种可能性是使用多个文件。将所有常用内容(moderncv 选项、包含的包、、等)存储\name
在\title
一个名为的文件中preamble.tex
,然后为 CV 创建一个文件:
\documentclass[11pt,a4paper,sans]{moderncv}
\input{preamble.tex}
\begin{document}
\makecvtitle
...
\end{document}
另附一个用于放置求职信的单独文件:
\documentclass[11pt,a4paper,sans]{moderncv}
\input{preamble.tex}
\begin{document}
\makelettertitle
...
\makeletterclosing
\end{document}
这种方式更简单,并且可以更容易地创建多封求职信(例如,发给不同的收件人)。