创建带有嵌入文本的水平条

创建带有嵌入文本的水平条

我正在将简历从 Word 格式转换为 LaTeX 格式。我想复制下面显示的功能:水平黑条,其中嵌入两段文本,分别向左和向右对齐。

在此处输入图片描述

我怎样才能用 LaTeX 达到同样的效果?

答案1

您可以使用tcolorbox

\documentclass{article}
\usepackage{tcolorbox}
\begin{document}
\begin{tcolorbox}[colback=black!50,colframe=black,colupper=white,
  arc=0pt,outer arc=0pt,top=1mm,bottom=1mm,left=1mm,right=1mm]
  Gap year \hfill July 2011--October 2012
\end{tcolorbox}
\end{document}

在此处输入图片描述

答案2

Tikz 示例:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[draw=black,fill=black!50!gray, text=white, text width=12cm](box){\textbf{Gap Year\hfill July 2011 - July 2012}};
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案3

有以下 3 种方法可以实现此目的:

\documentclass{article}
\usepackage[x11names, table]{xcolor}
\usepackage[showframe, nomarginpar]{geometry}
\usepackage{framed}
\definecolor{shadecolor}{named}{LightSteelBlue4}
\setlength\FrameSep{3pt}
\usepackage{array, tabularx} 

\begin{document}

\noindent\fcolorbox{SlateGray4!80}{SlateGray3}{\sffamily\color{white}%
\makebox[\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax]{Gap year\hfill July 2011--October 2012}}
\vskip\topsep
Some text some text some text some text some text some text some text some text some text

\begin{shaded*}\sffamily\color{NavajoWhite1!50}
\noindent Gap year\hfill July 2011--October 2012
\end{shaded*}
\color{black}
Some text some text some text some text some text some text some text some text some text

{\vskip\topsep\sffamily\color{white}\setlength\extrarowheight{1pt} \noindent\begin{tabularx}{\dimexpr\linewidth}{lXr}
\rowcolor{lightgray}Gap year & & July 2011--October 2012%
\end{tabularx}}

\end{document} 

在此处输入图片描述

相关内容