# How to align tcolorbox at the top?

I want to align Some text with Lead Programmer like this:

But the leftrulebox (a tcolorbox) inside the description environment doesn't align properly. The following code gives this:

The code:

\documentclass{article}
\usepackage[left=60pt,top=60pt,right=60pt,bottom=60pt]{geometry}
\usepackage{kantlipsum}
\usepackage{xcolor}
\usepackage{enumitem}
\setitemize{nolistsep,labelsep=1ex,leftmargin=*}
%% colors---
\definecolor{lightgray}{gray}{0.8}
%%items--
\newlist{items}{description}{1}
\setlist[items]{align=right,font=\normalfont, leftmargin=1.8in,style=nextline,labelsep=1em,}
%% leftrulebox---
\usepackage[many]{tcolorbox}
\tcbuselibrary{skins,breakable}
\newtcolorbox{leftrulebox}{
colback=white,
left=0.5ex,
top=0pt,
arc=0pt,
outer arc=0pt,
leftrule=1pt,
rightrule=0pt,
toprule=0pt,
bottomrule=0pt,
breakable,
enhanced jigsaw
}
%
%

\begin{document}
\begin{items}
\item[Some text]%
\begin{leftrulebox}
\par
\textbf{Lead Programmer}, Social Networks Inc \par
Some text \par some text
\begin{itemize}
\item Reengineered multiple systems that fueled improvements to productivity, eficiency, uptime and accuracy for global business operations. Developed code, system design and test/QA plans for all solutions and often coordinated the national or international rollout.
\item Led, architected and participated in the design, testing and deployment of client/server, multi-tier applications, ActiveX and related components.
\item Developed new procedures for requirements gathering, needs analysis, testing, scripting and documentation to strengthen quality and functionality of business-critical applications.
\end{itemize}

\kant[1-5]
\end{leftrulebox}
\end{items}
\end{document}


# Question

1. What causes this downward shift of Some text?
2. How to align Some text with Lead Programmer...

Caveat

1. I can't use any form of tabular (including longtable) as I need the rule to continue at a page break. longtable too won't break across pages inside a row.

# Edit:

As noted by Gonzalo, using \leavevmode and some negative vskip works for same kind of contents in the box. But for the code below, I had to give different vskips for different boxes:

\documentclass{article}
\usepackage[left=60pt,top=60pt,right=60pt,bottom=60pt]{geometry}
\usepackage{xcolor}
\usepackage{enumitem}
\setitemize{nolistsep,labelsep=1ex,leftmargin=*}
%% colors---
\definecolor{lightgray}{gray}{0.8}
%%items--
\newlist{items}{description}{1}
\setlist[items]{align=right,font=\normalfont, leftmargin=1.8in,style=nextline,labelsep=1em,}
%% leftrulebox---
\usepackage[many]{tcolorbox}
\tcbuselibrary{skins,breakable}
\newtcolorbox{leftrulebox}{
colback=white,
left=0.5ex,
top=0pt,
arc=0pt,
outer arc=0pt,
leftrule=1pt,
rightrule=0pt,
toprule=0pt,
bottomrule=0pt,
breakable,
nobeforeafter,
enhanced jigsaw,
before=\vskip-16.5pt       %% I want to define this here globally
}
%
%

\begin{document}
\section*{Objective}
\begin{items}
\item[Objective]%
\leavevmode
\begin{leftrulebox}
\kant[1]
\end{leftrulebox}
\end{items}

\section*{Positions}
\begin{items}
\item[\raggedleft 1/2010 -- 2/2012]%
\leavevmode
\begin{leftrulebox}
\textbf{Lead Programmer}, Social Networks Inc \par
Some text \par some text\par
\begin{itemize}%[labelsep=1ex]
\item Reengineered multiple systems that fueled improvements to productivity, eficiency, uptime and accuracy for global business operations. Developed code, system design and test/QA plans for all solutions and often coordinated the national or international rollout.
\item Led, architected and participated in the design, testing and deployment of client/server, multi-tier applications, ActiveX and related components.
\item Developed new procedures for requirements gathering, needs analysis, testing, scripting and documentation to strengthen quality and functionality of business-critical applications.
\end{itemize}
\end{leftrulebox}
\end{items}
\begin{items}
\item[1/2009 -- 2/2010]%
\leavevmode
\begin{leftrulebox}
\textbf{Programmer I}, The Coolest Search Engine \par
\begin{itemize}%[labelsep=1ex]
\item Led solutions engineering that involved process automation, macro conversion and functionality enhancement. Replaced time-consuming, error prone manual processes with elegant, automated solutions.
\item Developed and implemented cross-platform, Java-based POS system. Completed project under budget and three weeks ahead of deadline.
\item Coded new solutions that increased availability and scalability by 45\% and 75\%, respectively.
\end{itemize}
\end{leftrulebox}
\end{items}

\section*{Skills}
\begin{items}
\item[\textbf{Systems}]%
\leavevmode
\begin{leftrulebox}
\kant[1-2]
\end{leftrulebox}
\end{items}
\begin{items}
\item[\textbf{Others}]%
\leavevmode
\begin{leftrulebox}
some short text here
\end{leftrulebox}
\end{items}
\begin{items}
\item[\textbf{Databases}]%
\leavevmode
\begin{leftrulebox}
some short text here
\end{leftrulebox}
\end{items}

\end{document}


The alignment of items under Objective and Positions are satisfactory while with Systems, Others and Databases it is not. This happens because I have given a global vskip (which I want to give).

The amount by which the boxes move vertically depends on the content (AAArgh) and I can't define a global vskip.

Since, unfortunately, this script will be used in an automatic way where, I don't have control over the content, I can't determine the amount of vskip for different items. Hence, I can't define it globally. How to over come this?

-

## Updated version

After the edit with the question, I propose a different approach here not using a list to place the labels but reducing the width for the tcolorbox and using an optional argument (it could easily be turned into mandatory) and the overlay key to place the label at a fixed vertical position; since the label is placed inside a node of fixed width and with align=right, they admit line breaking and raggedleft texts (feel free to change the lengths according to your needs):

\documentclass{article}
\usepackage[left=60pt,top=60pt,right=60pt,bottom=60pt]{geometry}
\usepackage{xcolor}
\usepackage{kantlipsum}
\usepackage{enumitem}
\usepackage[many]{tcolorbox}

\setitemize{nolistsep,labelsep=1ex,leftmargin=*}

%% colors---
\definecolor{lightgray}{gray}{0.8}

%%items--
\newlist{items}{description}{1}
\setlist[items]{align=right,font=\normalfont, leftmargin=1.8in,style=nextline,labelsep=1em,}

%% leftrulebox---
\tcbuselibrary{skins,breakable}
\newtcolorbox{leftrulebox}[1][]{
colback=white,
left=0.5ex,
top=0pt,
arc=0pt,
outer arc=0pt,
enlarge left by=1.8in,
enlarge right by=-\dimexpr1.8in+\parindent\relax,
right=\dimexpr1.8in+\parindent\relax,
leftrule=1pt,
rightrule=0pt,
toprule=0pt,
bottomrule=0pt,
breakable,
nobeforeafter,
enhanced jigsaw,
overlay={
\node[anchor=north east,inner ysep=0pt,align=right,text width=1.5in]
at ([yshift=-0.55ex]frame.north west) {\hfill#1};
},
before=\vskip2\itemsep\noindent
}

\begin{document}

\section*{Objective}

\begin{leftrulebox}[Objective]
\kant[1]
\end{leftrulebox}

\section*{Positions}

\begin{leftrulebox}[1/2010 -- 2/2012]
\textbf{Lead Programmer}, Social Networks Inc \par
Some text \par some text
\begin{itemize}
\item Reengineered multiple systems that fueled improvements to productivity, eficiency, uptime and accuracy for global business operations. Developed code, system design and test/QA plans for all solutions and often coordinated the national or international rollout.
\item Led, architected and participated in the design, testing and deployment of client/server, multi-tier applications, ActiveX and related components.
\item Developed new procedures for requirements gathering, needs analysis, testing, scripting and documentation to strengthen quality and functionality of business-critical applications.
\end{itemize}
\end{leftrulebox}

\begin{leftrulebox}[1/2009 -- 2/2010]
\textbf{Programmer I}, The Coolest Search Engine
\begin{itemize}
\item Led solutions engineering that involved process automation, macro conversion and functionality enhancement. Replaced time-consuming, error prone manual processes with elegant, automated solutions.
\item Developed and implemented cross-platform, Java-based POS system. Completed project under budget and three weeks ahead of deadline.
\item Coded new solutions that increased availability and scalability by 45\% and 75\%, respectively.
\end{itemize}
\end{leftrulebox}

\section*{Skills}

\begin{leftrulebox}[\textbf{Systems}]
\kant[1-2]
\end{leftrulebox}

\begin{leftrulebox}[\textbf{Others}]
some short text here
\end{leftrulebox}

\begin{leftrulebox}[\textbf{Databases}]
some short text here
\end{leftrulebox}

\end{document}


Some images showing the label alignment:

## First version

After \item[some text] TeX is in vertical mode and this produces the undesired effect. Add \leavevmode.

\documentclass{article}
\usepackage[left=60pt,top=60pt,right=60pt,bottom=60pt]{geometry}
\usepackage{kantlipsum}
\usepackage{xcolor}
\usepackage{enumitem}
\setitemize{nolistsep,labelsep=1ex,leftmargin=*}
%% colors---
\definecolor{lightgray}{gray}{0.8}
%%items--
\newlist{items}{description}{1}
\setlist[items]{align=right,font=\normalfont, leftmargin=1.8in,style=nextline,labelsep=1em,}
%% leftrulebox---
\usepackage[many]{tcolorbox}
\tcbuselibrary{skins,breakable}
\newtcolorbox{leftrulebox}{
colback=white,
left=0.5ex,
top=0pt,
arc=0pt,
outer arc=0pt,
leftrule=1pt,
rightrule=0pt,
toprule=0pt,
bottomrule=0pt,
breakable,
enhanced jigsaw,
before=\vskip-13.5pt
}
%
%

\begin{document}
\begin{items}
\item[Some text]%
\leavevmode
\begin{leftrulebox}
\par
\textbf{Lead Programmer}, Social Networks Inc \par
Some text \par some text
\begin{itemize}
\item Reengineered multiple systems that fueled improvements to productivity, eficiency, uptime and accuracy for global business operations. Developed code, system design and test/QA plans for all solutions and often coordinated the national or international rollout.
\item Led, architected and participated in the design, testing and deployment of client/server, multi-tier applications, ActiveX and related components.
\item Developed new procedures for requirements gathering, needs analysis, testing, scripting and documentation to strengthen quality and functionality of business-critical applications.
\end{itemize}

\kant[1-5]
\end{leftrulebox}
\end{items}
\end{document}


Using just \leavevmode the box will be slightly down, due to the regular spacing before a tcolorbox; you can correct this by using a convenient \vskip for before either globally (as in my example) or locally, by adding an optional argument to pass options to the tcolorbox:

\documentclass{article}
\usepackage[left=60pt,top=60pt,right=60pt,bottom=60pt]{geometry}
\usepackage{kantlipsum}
\usepackage{xcolor}
\usepackage{enumitem}
\setitemize{nolistsep,labelsep=1ex,leftmargin=*}
%% colors---
\definecolor{lightgray}{gray}{0.8}
%%items--
\newlist{items}{description}{1}
\setlist[items]{align=right,font=\normalfont, leftmargin=1.8in,style=nextline,labelsep=1em,}
%% leftrulebox---
\usepackage[many]{tcolorbox}
\tcbuselibrary{skins,breakable}
\newtcolorbox{leftrulebox}[1][]{
colback=white,
left=0.5ex,
top=0pt,
arc=0pt,
outer arc=0pt,
leftrule=1pt,
rightrule=0pt,
toprule=0pt,
bottomrule=0pt,
breakable,
enhanced jigsaw,
#1
}
%
%

\begin{document}
\begin{items}
\item[Some text]
\leavevmode
\begin{leftrulebox}[before=\vskip-13.5pt]
\par
\textbf{Lead Programmer}, Social Networks Inc \par
Some text \par some text
\begin{itemize}
\item Reengineered multiple systems that fueled improvements to productivity, eficiency, uptime and accuracy for global business operations. Developed code, system design and test/QA plans for all solutions and often coordinated the national or international rollout.
\item Led, architected and participated in the design, testing and deployment of client/server, multi-tier applications, ActiveX and related components.
\item Developed new procedures for requirements gathering, needs analysis, testing, scripting and documentation to strengthen quality and functionality of business-critical applications.
\end{itemize}

\kant[1-5]
\end{leftrulebox}
\end{items}
\end{document}

-
@HarishKumar I did some tests with different amounts of text and everything worked OK with the same length for the \vskip. I'll be looking forward to seeing your edit. – Gonzalo Medina Apr 10 '14 at 23:43
@HarishKumar You're right. My test examples were deceiving. Now a new idea has formed in my head. Would you be willing to use a different approach? (not using a list at all, but keeping the tcolorboxes). – Gonzalo Medina Apr 10 '14 at 23:51
Sure; it will break across pages. Will the leftrulebox always start at the same constant distance from the left margin? If this is so, my idea could work; otherwise, I can discard it :) – Gonzalo Medina Apr 11 '14 at 0:00
@HarishKumar You're welcome! Thanks for the bounty :) Have a nice weekend you too! – Gonzalo Medina Apr 11 '14 at 12:33

I want suggest another possibility. It still needs some work but let me know if it's interesting.

\tcolorboxes have upper and lower parts which can be placed side by side. Therefore instead of trying to align some external text with a tcolorbox text, place both inside. External text will be upper text and interior one will be lower text and left hand rule will be segmentation rule inside tcolorbox.

I couldn't find how to customize segmentation line but I've solved using overlays.

They main problem still to solve is how to automatically decide lefthand width to fix enough space for left hand column. I've tried with \widthof but didn't worked.

\documentclass{article}
\usepackage[left=60pt,top=60pt,right=60pt,bottom=60pt]{geometry}
\usepackage{kantlipsum}
\usepackage{xcolor}
\usepackage{enumitem}
\usepackage{calc}
\setitemize{nolistsep,labelsep=1ex,leftmargin=*}
%% colors---
\definecolor{lightgray}{gray}{0.8}
%%items--
\newlist{items}{description}{1}
\setlist[items]{align=right,font=\normalfont, leftmargin=1.8in,style=nextline,labelsep=1em,}
%% leftrulebox---
\usepackage[many]{tcolorbox}
\tcbuselibrary{skins,breakable}
\newtcolorbox{leftrulebox}{
colback=white,
left=0.5ex,
top=0pt,
arc=0pt,
outer arc=0pt,
leftrule=0pt,
rightrule=0pt,
toprule=0pt,
bottomrule=0pt,
breakable,
enhanced jigsaw,
sidebyside,sidebyside align=top,
lefthand width=2cm,
segmentation hidden,
overlay={\draw[red] (segmentation.north)--(segmentation.south);}
}

\begin{document}
\begin{leftrulebox}
Some text
\tcblower
\textbf{Lead Programmer}, Social Networks Inc \par
Some text \par some text
\begin{itemize}
\item Reengineered multiple systems that fueled improvements to productivity, eficiency, uptime and accuracy for global business operations. Developed code, system design and test/QA plans for all solutions and often coordinated the national or international rollout.
\item Led, architected and participated in the design, testing and deployment of client/server, multi-tier applications, ActiveX and related components.
\item Developed new procedures for requirements gathering, needs analysis, testing, scripting and documentation to strengthen quality and functionality of business-critical applications.
\end{itemize}

\kant[1]
\end{leftrulebox}
\end{document}


-
Nice idea but unfortunately, I had already tried it. As I wanted page breaks, and this won't break across pages, I gave up (sidebyside won't break). Sorry. But don't delete your answer, it may be useful to somebody. Thanks for trying out. Have a nice day and weekend. :) – Harish Kumar Apr 11 '14 at 7:27
@HarishKumar: You're right, I've forgotten it. I cannot test it now but do you think that using a tcbox (size adjusted to content) for left hand text and a breakable tcolorbox (with calculated width) for right hand text has any sense? This way both top lines would be aligned. – Ignasi Apr 11 '14 at 22:02
Ignasi: Any new idea (however odd it may sound) is welcome. If you want to try anything like that please go ahead. If I like that and if it works, I will give you a bounty for sure. :) – Harish Kumar Apr 11 '14 at 22:29