我一直尝试在 LaTeX 中为我的简历实现以下垂直侧边栏效果,但结果发现它比我想象的要困难得多(在 InDesign 中可以轻松创建):
我尝试了所有能想到的方法 — 横向的minipage
s、parbox
es、table
s、multirow
s 等等,但都无法复制。我已经很接近了,但从未成功让标题与表格顶部齐平(更不用说居中水平规则了)。有没有关于如何实现这一点的见解?
作为参考,这是我最近尝试使用表格实现此功能multirow
(需要 XeLaTeX):
\documentclass{article}
\usepackage{fontspec, multirow, rotating, tabularx, xunicode}
\def\Vhrulefill{\leavevmode\leaders\hrule height 0.7ex depth \dimexpr0.4pt-0.7ex\hfill\kern0pt}
\begin{document}
\begin{tabularx}{\textwidth}{l X}
& \textbf{Spoken Languages} \\
& English, Hebrew (fluent in speaking, reading, and writing) \\
& \\
& \textbf{Programming Languages} \\
& Objective-C, C, Ruby, Java, Python, HTML + CSS/SASS + JavaScript/CoffeeScript \\
& \emph{Familiar with C++, Haskell, PHP} \\
& \\
& \textbf{Technologies} \\
& OS X, iOS, Xcode, Unix/Linux Systems, LaTeX, Shell Scripting, Git, Vim, Jekyll \\
& \emph{Familiar with Windows, Windows Server, MySQL} \\
\multirow{-9}{*}{\begin{sideways}\Vhrulefill~skills\end{sideways}} &
\end{tabularx}
\end{document}
输出结果如下:
更新:我认为我会选择沃纳的答案,因为它很适合我的需要;然而,我一直在尝试以更通用的形式来获取它,以便我可以轻松地重复使用它,但我遇到了麻烦。
我为此创建了一个新的环境,但不幸的是,我无法使用文本的高度使标签沿正文顶部正确对齐:
\documentclass{article}
\usepackage{graphicx, tabularx, xcolor}
\usepackage{environ}
\usepackage[margin=1in]{geometry}
\newlength{\sectionheight}
\newlength{\tablewidth}
\NewEnviron{rsection}[3]{%
\setlength{\tablewidth}{#2}
\addtolength{\tablewidth}{-1ex}
\settoheight{\sectionheight}{\begin{tabularx}{\tablewidth}{l #3}\BODY\end{tabularx}}
\begin{tabularx}{\tablewidth}{l #3}
\BODY \\
\raisebox{\normalbaselineskip}{\smash{\rotatebox{90}{%
\color{black!33}\rule[.5ex]{\sectionheight}{.4pt}\llap{\colorbox{white}{\color{black!66}#1}}
}}} &
\end{tabularx}
}
\begin{document}
\begin{rsection}{education}{0.5\textwidth}{X}
& \textbf{Binghamton University, State University of New York} \\
& B.S. — Computer Science · Expected 2016 \\
& \\
& Binghamton University Scholars Program \\
& Binghamton President's Scholars Program
\end{rsection}
\begin{rsection}{skills}{0.5\textwidth}{X}
& \textbf{Spoken Languages} \\
& English, Hebrew (fluent in speaking, reading, and writing) \\
& \\
& \textbf{Programming Languages} \\
& Objective-C, C, Ruby, Java, Python, HTML, CSS, SASS, JavaScript, CoffeeScript \\
& \emph{Familiar with C++, Haskell, PHP} \\
& \\
& \textbf{Technologies} \\
& OS X, iOS, Xcode, Unix/Linux Systems, LaTeX, Shell Scripting, Git, Vim, Jekyll \\
& \emph{Familiar with Windows, Windows Server, MySQL}
\end{rsection}
\end{document}
由于某种原因,\settoheight{\sectionheight}{\begin{tabularx}{\tablewidth}{l #3}\BODY\end{tabularx}}
没有返回文本的正确高度,因此结果如下所示:
我希望标签看起来正确,表格彼此对齐。知道哪里出了问题吗?
答案1
这是获取结果的非常手动的尝试。由于垂直规则 + 文本跨越表格的 12 行(在我的示例中),我绘制了\rule
长度为 的线12\normalbaselineskip
,然后将其旋转到位:
\documentclass{article}
\usepackage{graphicx, tabularx, xcolor}% http://ctan.org/pkg/{graphicx,tabularx,xcolor}
\begin{document}
\begin{tabularx}{\textwidth}{l X}
& \textbf{Spoken Languages} \\
& English, Hebrew (fluent in speaking, reading, and writing) \\
& \\
& \textbf{Programming Languages} \\
& Objective-C, C, Ruby, Java, Python, HTML + CSS/SASS + JavaScript/CoffeeScript \\
& \emph{Familiar with C++, Haskell, PHP} \\
& \\
& \textbf{Technologies} \\
& OS X, iOS, Xcode, Unix/Linux Systems, LaTeX, Shell Scripting, Git, Vim, Jekyll \\
\smash{\rotatebox{90}{%
\color{black!20}\rule[.5ex]{12\normalbaselineskip}{.4pt}\llap{\colorbox{white}{\color{black!75}skills}}%
}} &
\emph{Familiar with Windows, Windows Server, MySQL}
\end{tabularx}
\end{document}
graphicx
提供\rotatebox{<degrees>}{<stuff>}
同时xcolor
允许更改文本/规则颜色。我已经放弃了multirow
因为\smash
删除了其参数的垂直高度。
也可以使用zref
的savepos
模块来识别的开始/结束rsection
,并相应地插入规则:
\documentclass{article}
\usepackage{graphicx, tabularx, xcolor, environ}% http://ctan.org/pkg/{graphicx,tabularx,xcolor,environ}
\usepackage{zref-savepos}% http://ctan.org/pkg/zref
\usepackage[margin=1in]{geometry}% http://ctan.org/pkg/geometry
\makeatletter
% Taken from http://tex.stackexchange.com/a/69076/5764
% \zsaveposx/y is defined since 2011/12/05 v2.23 of zref-savepos
\@ifundefined{zsaveposy}{\let\zsaveposy\zsavepos}{}
\newlength{\tablewidth}
\newcounter{@rsection}
\NewEnviron{rsection}[3]{%
% #1 = label
% #2 = tabularx width
% #3 = column specification
\setlength{\tablewidth}{#2}%
\stepcounter{@rsection}% Mark labels top/bottom based on rsection counter
%
\noindent\begin{tabularx}{\tablewidth}{l #3}
\zsaveposy{rsection-top-\the@rsection}% Store top y-position
\BODY \\[-\normalbaselineskip]% Place content
\zsaveposy{rsection-bot-\the@rsection}% Store bottom y-position
\zref@refused{rsection-top-\the@rsection}%
\zref@refused{rsection-bot-\the@rsection}%
\smash{\rotatebox{90}{%
\color{black!33}%
\rule[.5ex]{\dimexpr\normalbaselineskip+\zposy{rsection-top-\the@rsection}sp-\zposy{rsection-bot-\the@rsection}sp}{.4pt}%
\llap{\colorbox{white}{\color{black!66}#1}}
}} &
\end{tabularx}%
}
\makeatother
\begin{document}
\begin{rsection}{education}{0.5\textwidth}{X}
& \textbf{Binghamton University, State University of New York} \\
& B.S. — Computer Science · Expected 2016 \\
& \\
& Binghamton University Scholars Program \\
& Binghamton President's Scholars Program
\end{rsection}%
\begin{rsection}{skills}{0.5\textwidth}{X}
& \textbf{Spoken Languages} \\
& English, Hebrew (fluent in speaking, reading, and writing) \\
& \\
& \textbf{Programming Languages} \\
& Objective-C, C, Ruby, Java, Python, HTML, CSS, SASS, JavaScript, CoffeeScript \\
& \emph{Familiar with C++, Haskell, PHP} \\
& \\
& \textbf{Technologies} \\
& OS X, iOS, Xcode, Unix/Linux Systems, LaTeX, Shell Scripting, Git, Vim, Jekyll \\
& \emph{Familiar with Windows, Windows Server, MySQL}
\end{rsection}
\end{document}
在上面的例子中,标签rsection-bot-\the@rsection
和分别rsection-top-\the@rsection
存储表格底部和顶部的 y 位置(以缩放点/sp
秒为单位)。适当\dimexpr
计算表格的高度并在第一列插入规则(如前所述)。
答案2
这是一个自动化解决方案,允许分页符(在表格跨越多页的情况下);您所要做的就是使用环境将表格括起来tikzborder
,并提供标签作为强制参数:
\documentclass{article}
\usepackage{fontspec, tabularx,xunicode}
\usepackage{longtable}
\usepackage{atbegshi}
\usepackage{refcount}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}
\newcounter{bordercntr}
\newcounter{borderpages}
\newcommand\tikzmark[1]{%
\tikz[overlay,remember picture] \node (#1) {};}
\newenvironment{tikzborder}[1]
{%
\gdef\bordertitle{#1}
\stepcounter{bordercntr}%
\tikzmark{start-border}\label{start-border\thebordercntr}%
\ifnum\getpagerefnumber{start-border\thebordercntr}=\getpagerefnumber{end-border\thebordercntr} \else
\begin{tikzpicture}[overlay, remember picture]
\draw [ultra thick,gray]
let \p1 = (start-border.south), \p2 = (end-border), \p3 = (current page.center) in%
( $ (\x3,\y1) + (-.55\textwidth,2pt) $ ) -- ( $ (\x3,\y3) + (-0.55\textwidth,-0.5\textheight-15pt) $ );
\end{tikzpicture}%
\begin{tikzpicture}[overlay, remember picture]
\path let \p1 = (start-border.south), \p2 = (current page.center) in%
node[rotate=90,fill=white,anchor=east,font=\color{black!70}\sffamily] at ( $ (\x2,\y1) + (-.55\textwidth,2pt) $ ) {\bordertitle};
\end{tikzpicture}
\setcounter{borderpages} {\numexpr\getpagerefnumber{end-border\thebordercntr}-\getpagerefnumber{start-border\thebordercntr}}\theborderpages
\ifnum\value{borderpages}>1
\AtBeginShipoutNext{\tikzborderpage}%
\fi
\fi%
}
{\tikzmark{end-border}\label{end-border\thebordercntr}
\ifnum\getpagerefnumber{start-border\thebordercntr}=\getpagerefnumber{end-border\thebordercntr}
\begin{tikzpicture}[overlay, remember picture]
\draw [ultra thick,gray]
let \p1 = (start-border.south), \p2 = (end-border), \p3 = (current page.center) in
( $ (\x3,\y1) + (-.55\textwidth,2pt) $ ) -- ( $ (\x3,\y2) + (-.55\textwidth,10pt) $ );
\end{tikzpicture}%
\begin{tikzpicture}[overlay, remember picture]
\path let \p1 = (start-border.south), \p2 = (current page.center) in%
node[rotate=90,fill=white,anchor=east,font=\color{black!70}\sffamily] at ( $ (\x2,\y1) + (-.55\textwidth,2pt) $ ) {\bordertitle};
\end{tikzpicture}
\else
\begin{tikzpicture}[overlay, remember picture]
\draw [ultra thick,gray]
let \p1 = (start-border.north), \p2 = (end-border), \p3 = (current page.center) in
( $ (\x3,\y3) + (-.55\textwidth,.5\textheight-6pt) $ ) -- ( $ (\x3,\y2) + (-.55\textwidth,20pt) $ );
\end{tikzpicture}%
\fi%
}
\newcommand\tikzborderpage{%
\begin{tikzpicture}[overlay, remember picture]
\draw [ultra thick,gray]
let \p1 = (current page.center) in
( $ (\x1,\y1) + (-.55\textwidth,0.5\textheight-15pt) $ ) -- ( $ (\x1,\y1) + (-.55\textwidth,-0.5\textheight) $ );
\end{tikzpicture}
\addtocounter{borderpages}{-1}%
\ifnum\value{borderpages}>1
\AtBeginShipoutNext{\tikzborderpage}%
\fi%
}
\begin{document}
\begin{tikzborder}{skills}
\noindent\begin{tabularx}{\textwidth}{X}
\textbf{Spoken Languages} \\
English, Hebrew (fluent in speaking, reading, and writing) \\
\\
\textbf{Programming Languages} \\
Objective-C, C, Ruby, Java, Python, HTML + CSS/SASS + JavaScript/CoffeeScript \\
\emph{Familiar with C++, Haskell, PHP} \\
\\
\textbf{Technologies} \\
OS X, iOS, Xcode, Unix/Linux Systems, LaTeX, Shell Scripting, Git, Vim, Jekyll \\
\emph{Familiar with Windows, Windows Server, MySQL} \\
\end{tabularx}
\end{tikzborder}
\begin{tikzborder}{expertise}
\begin{longtable}{p{.7\textwidth}}
\textbf{Spoken Languages} \\
English, Hebrew (fluent in speaking, reading, and writing) \\
\\
\textbf{Programming Languages} \\
Objective-C, C, Ruby, Java, Python, HTML + CSS/SASS + JavaScript/CoffeeScript \\
\emph{Familiar with C++, Haskell, PHP} \\
\\
\textbf{Technologies} \\
OS X, iOS, Xcode, Unix/Linux Systems, LaTeX, Shell Scripting, Git, Vim, Jekyll \\
\emph{Familiar with Windows, Windows Server, MySQL} \\
\textbf{Spoken Languages} \\
English, Hebrew (fluent in speaking, reading, and writing) \\
\\
\textbf{Programming Languages} \\
Objective-C, C, Ruby, Java, Python, HTML + CSS/SASS + JavaScript/CoffeeScript \\
\emph{Familiar with C++, Haskell, PHP} \\
\\
\textbf{Technologies} \\
OS X, iOS, Xcode, Unix/Linux Systems, LaTeX, Shell Scripting, Git, Vim, Jekyll \\
\emph{Familiar with Windows, Windows Server, MySQL} \\
\textbf{Spoken Languages} \\
English, Hebrew (fluent in speaking, reading, and writing) \\
\\
\textbf{Programming Languages} \\
Objective-C, C, Ruby, Java, Python, HTML + CSS/SASS + JavaScript/CoffeeScript \\
\emph{Familiar with C++, Haskell, PHP} \\
\\
\textbf{Technologies} \\
OS X, iOS, Xcode, Unix/Linux Systems, LaTeX, Shell Scripting, Git, Vim, Jekyll \\
\emph{Familiar with Windows, Windows Server, MySQL} \\
\textbf{Spoken Languages} \\
English, Hebrew (fluent in speaking, reading, and writing) \\
\\
\textbf{Programming Languages} \\
Objective-C, C, Ruby, Java, Python, HTML + CSS/SASS + JavaScript/CoffeeScript \\
\emph{Familiar with C++, Haskell, PHP} \\
\\
\textbf{Technologies} \\
OS X, iOS, Xcode, Unix/Linux Systems, LaTeX, Shell Scripting, Git, Vim, Jekyll \\
\emph{Familiar with Windows, Windows Server, MySQL} \\
\textbf{Spoken Languages} \\
English, Hebrew (fluent in speaking, reading, and writing) \\
\\
\textbf{Programming Languages} \\
Objective-C, C, Ruby, Java, Python, HTML + CSS/SASS + JavaScript/CoffeeScript \\
\emph{Familiar with C++, Haskell, PHP} \\
\\
\textbf{Technologies} \\
OS X, iOS, Xcode, Unix/Linux Systems, LaTeX, Shell Scripting, Git, Vim, Jekyll \\
\emph{Familiar with Windows, Windows Server, MySQL} \\
\textbf{Spoken Languages} \\
English, Hebrew (fluent in speaking, reading, and writing) \\
\\
\textbf{Programming Languages} \\
Objective-C, C, Ruby, Java, Python, HTML + CSS/SASS + JavaScript/CoffeeScript \\
\emph{Familiar with C++, Haskell, PHP} \\
\\
\textbf{Technologies} \\
OS X, iOS, Xcode, Unix/Linux Systems, LaTeX, Shell Scripting, Git, Vim, Jekyll \\
\emph{Familiar with Windows, Windows Server, MySQL} \\
\textbf{Spoken Languages} \\
English, Hebrew (fluent in speaking, reading, and writing) \\
\\
\textbf{Programming Languages} \\
Objective-C, C, Ruby, Java, Python, HTML + CSS/SASS + JavaScript/CoffeeScript \\
\emph{Familiar with C++, Haskell, PHP} \\
\\
\textbf{Technologies} \\
OS X, iOS, Xcode, Unix/Linux Systems, LaTeX, Shell Scripting, Git, Vim, Jekyll \\
\emph{Familiar with Windows, Windows Server, MySQL} \\
\end{longtable}
\end{tikzborder}
\end{document}