在自定义 tcolorbox 的细列中仅获得最少的换行

在自定义 tcolorbox 的细列中仅获得最少的换行

这个答案: https://tex.stackexchange.com/a/170767/69378对我来说,这是一个非常有用且用途广泛的tcolorbox。这个答案已经满足了我近一年的页面设计,但我很好奇,想知道如何才能使左栏中的文本换行和/或连字?当我有两个中等长度的单词或在此栏中留下简短的注释时,如果它可以换行和/或连字会更好。

我已经尝试过了(并且会尝试继续更新此列表),但无济于事

下面的 MWE 取自上面链接的答案,并快速调整以显示(在我看来)tcolorbox在换行或连字方面并不是很激进。

\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.8cm,
    enlarge right by=-\dimexpr1.8cm+\parindent\relax,
    right=\dimexpr1.8cm+\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 and a nice long string here}]
\kant[1-3]
\end{leftrulebox}

\begin{leftrulebox}[\textbf{Others, oh so many others}]
some short text here\\
some short text here\\
some short text here \\
some short text here \\
\end{leftrulebox}

\begin{leftrulebox}[\textbf{(Databases of all different sorts)}]
some short text here\\
some short text here\\
some short text here \\
some short text here \\
\end{leftrulebox}

\end{document}

答案1

很难猜出您要寻找的布局,但这会将宽度减小到 1 英寸,使换行更容易,并用于ragged2e允许右侧不规则和连字符。我还删除了两个\\生成未满水平盒警告的元素。

在此处输入图片描述

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

\usepackage[newcommands]{ragged2e}
\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.8cm,
    enlarge right by=-\dimexpr1.8cm+\parindent\relax,
    right=\dimexpr1.8cm+\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=1in] 
        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 and a nice long string here}]
\kant[1-3]
\end{leftrulebox}

\begin{leftrulebox}[\textbf{Others, oh so many others}]
some short text here\\
some short text here\\
some short text here \\
some short text here 
\end{leftrulebox}

\begin{leftrulebox}[\textbf{(Databases of all different sorts)}]
some short text here\\
some short text here\\
some short text here \\
some short text here 
\end{leftrulebox}

\end{document}

相关内容