我正在使用一个使用基础类的模板scrartcl
。在这个类中,我有两个命令(\part
和\personal
),都使用tabularx
。我试图将\part
使用命令生成的框作为的第二个参数\personal
。
将命令作为参数会出现错误,而且,当我添加tabularx
到命令时\part
,即使我指定了,文本也不再居中\begin{center}
。
以下是包含所有命令的类:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{tccv}
[2012/11/09 v1.0
Two Column Curriculum Vitae]
\LoadClass[10pt]{scrartcl}
\setcounter{secnumdepth}{-1}
\RequirePackage[hmargin=1.25cm,vmargin=1.25cm,twocolumn,columnsep=1.25cm]{geometry}
\RequirePackage{bookman,etoolbox,hyperref,needspace,tabularx,xcolor,fontawesome}
% Capitalize words of at least a minimum length (default to 3 chars).
% The text is capitalized before being expanded.
%
% This macro uses Lua to do the job but fails gracefully (that is,
% return the text as is) if \directlua is not available.
%
% |[
% \ucwords[optional: miminum length]{text}
% ]|
\newcommand\ucwords[2][3]{%
% Fails gracefully if not in LuaLaTeX
\providecommand\directlua[1]{#2}%
\directlua{%
local minlen=tonumber("#1")
local src="\luaescapestring{\unexpanded{#2}}"
local dst={}
for w in src:gmatch('[^\string\%s]+') do
if w:len() >= minlen then w = w:sub(1,1):upper()..w:sub(2) end
table.insert(dst, w)
end
tex.print(dst)}}
\pagestyle{empty}
\setlength\parindent{0pt}
\color[HTML]{303030} % Default foreground color
\definecolor{link}{HTML}{506060} % Hyperlinks
\hypersetup{colorlinks,breaklinks,urlcolor=link,linkcolor=link}
\setkomafont{disposition}{\color[HTML]{0058B6}}
\setkomafont{section}{\scshape\Large\mdseries}
% In tccv \part must contain the subject of the curriculum vitae.
% The command will start a new page and output in onecolumn the
% subject (first and last name) with the hardcoded text
% "Curriculum vitae" under it.
\renewcommand\part[2]{%
\twocolumn[%
\begin{center}
\vskip-\lastskip%
\begin{tabularx}{\linewidth}{ r | l }
{\usekomafont{part} #1} & {#2} %\medskip\\
%{\fontfamily{pzc}\selectfont\Huge Curriculum vitae}
\end{tabularx}
\bigskip
\end{center}]}
% Overrides the \section command to capitalize every
% word for cosmetic purposes and draws a rule under it.
\makeatletter
\let\old@section\section
\renewcommand\section[2][]{%
\old@section[#1]{\ucwords{#2}}%
\newdimen\raising%
\raising=\dimexpr-0.7\baselineskip\relax%
\vskip\raising\hrule height 0.4pt\vskip-\raising}
\makeatother
% Allow conditionals based on the job name. This can usually be set
% from a command-line argument: check fausto.en.tex for an example.
%
% |[
% \ifjob{jobname}{content if matches}{content if does not match}
% ]|
\newcommand\ifjob[3]{%
\edef\JOBNAME{\jobname}%
\edef\PIVOT{\detokenize{#1}}%
\ifdefstrequal{\JOBNAME}{\PIVOT}{#2}{#3}%
}
% Renders a personal data box:
%
% |[
% \personal[optional: web site without scheme (no http:// prefix)]
% {address}{phone number}{email}
% ]|
\newcommand\personal[4][]{%
\needspace{0.5\textheight}%
\newdimen\boxwidth%
\boxwidth=\dimexpr\linewidth-2\fboxsep\relax%
\colorbox[HTML]{C7E2F2}{%
\begin{tabularx}{\boxwidth}{c|X}
\faMapMarker & {#2}\smallskip\\
\faPhone & {#3}\smallskip\\
\faEnvelope & \href{mailto:#4}{#4}
\ifstrempty{#1}{}{\smallskip\\ \faLinkedin & \href{http://www.#1}{#1}}
\end{tabularx}}}
% Use only \item inside this environment: no other macros
% are allowed:
%
% |[
% \item{fact}{description}
% ]|
\newenvironment{factlist}{%
\newdimen\unbaseline
\unbaseline=\dimexpr-\baselinestretch\baselineskip\relax
\renewcommand\item[2]{%
\textsc{##1} & {\raggedright ##2\medskip\\}\\[\unbaseline]}
\tabularx{\linewidth}{rX}}
{\endtabularx}
%% End of file `tccv.cls'.
这是乳胶文档:
\documentclass{tccv}
\usepackage[english]{babel}
\usepackage{fontawesome}
\usepackage[gen]{eurosym}
\begin{document}
\part{Name}{\personal
{Address }
{+33 654 32 10 98}
{[email protected]}}
\section{Languages}
\begin{factlist}
\item{Spanish}{Native speaker}
\item{English}{Level C2 }
\item{French}{Level C1 }
\end{factlist}
\section{Software skills}
Python $\bullet$ Java $\bullet$ JavaScript $\bullet$ Matlab $\bullet$ Android Studio $\bullet$ Microsoft Office $\bullet$ C $\bullet$ \LaTeX $\bullet$ Solid Edge $\bullet$ Altium $\bullet$ Arduino
\end{document}
所以基本上我想用蓝框代替盒子应该放在这里,如图所示。提前感谢您的建议!
编辑:我已经清理了代码。说到将命令\part
居中,我的意思是姓名位于页面中央(通常布局是两列,所以我只希望名称|框位于页面中央。
编辑2:我已经根据我想要实现的目标更改了乳胶文档,但出现了错误。
答案1
目前尚不清楚您想要什么作为中心。
这里有两个简化的版本。
\begin{filecontents}{tccv.cls}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{tccv} [2012/11/09 v1.0 Two Column Curriculum Vitae]
\LoadClass[10pt]{scrartcl}
\RequirePackage[hmargin=1.25cm,vmargin=1.25cm,twocolumn,columnsep=1.25cm]{geometry}
\RequirePackage{array,tabularx}
\pagestyle{empty}
\setlength\parindent{0pt}
\renewcommand\part[2]{%
\twocolumn[%
\begin{center}
\vskip-\lastskip%
\begin{tabularx}{\linewidth}{ r | >{\centering\arraybackslash}X }
{\usekomafont{part} #1} & {#2}
\end{tabularx}
\bigskip
\end{center}]}
\endinput
\end{filecontents}
\documentclass{tccv}
\begin{document}
\part{Name}{Here is where the box should go}
\end{document}
请注意,这里的所有center
环境所做的就是添加垂直空间,因为表格很\linewidth
宽,所以占用整行。
如果你不想这样,你可能会想要
\renewcommand\part[2]{%
\twocolumn[%
\vskip-\lastskip%
\begin{tabularx}{\linewidth}{ X | X }
{\usekomafont{part} \hfill #1} & {#2}
\end{tabularx}
\bigskip]}
更可能的是,您不想要任何一个版本,而是更想要如下所示的版本。
\renewcommand\part[2]{%
\twocolumn[%
\vskip-\lastskip
{\usekomafont{part}\hfill #1 \textbar\ }#2\hfill\bigskip\par]}