如何在文字後面建立標題行

如何在文字後面建立標題行

文字後面跟著標題行

你好,

我希望為簡歷重新創建上述風格。對於履歷中各部分的標題,我希望部分名稱(在上面的範例中 - 教育)後面跟隨一個標題行,填充該行的其餘部分。

如果有人能告訴我該怎麼做,那就太好了。

下麵包含另一個範例。在這一圖中,文字出現在中間,兩側被標題行包圍。

後面和前面都有標題行段的文本

答案1

這是使用的一種可能性titlesecxhfill套餐:

\documentclass{article}
\usepackage[explicit]{titlesec}
\usepackage{xhfill}
\usepackage{lipsum}% just to generate text for the example

\titleformat{\section}
  {\normalfont\Large\bfseries}{}{0em}{#1~\xrfill[0.3ex]{1.5pt}}

\begin{document}

\section{Education}
\lipsum[4]

\end{document}

在此輸入影像描述

還有另一種風格:

\documentclass{article}
\usepackage[explicit]{titlesec}
\usepackage{xhfill}
\usepackage{lipsum}% just to generate text for the example

\titleformat{\section}
  {\normalfont\Large\bfseries\filcenter}{}{0em}{\xrfill[0.3ex]{1.5pt}~#1~\xrfill[0.3ex]{1.5pt}}

\begin{document}

\section{Education}
\lipsum[4]

\end{document}

在此輸入影像描述

如果標題很長,那麼可以使用 minipage 或可變寬度(透過 varwidth)套件來產生類似以下內容的內容:

\documentclass{article}
\usepackage[explicit]{titlesec}
\usepackage{xhfill}
\usepackage{varwidth}
\usepackage{lipsum}% just to generate text for the example

\newlength\mylen

\titleformat{\section}
  {\normalfont\Large\bfseries}{}{0em}
  {\begin{varwidth}{.7\linewidth}\raggedright#1\end{varwidth}~\xrfill[0.3ex]{1.5pt}}

\begin{document}

\section{Education}
\lipsum[4]
\section{Education and other extra activities}
\lipsum[4]

\end{document}

在此輸入影像描述

可以對其他樣式執行類似的操作:

\documentclass{article}
\usepackage[explicit]{titlesec}
\usepackage{xhfill}
\usepackage{varwidth}
\usepackage{lipsum}% just to generate text for the example

\newlength\mylen

\titleformat{\section}
  {\normalfont\Large\bfseries\filcenter}{}{0em}
  {\xrfill[0.3ex]{1.5pt}~\begin{varwidth}{.75\linewidth}\centering#1\end{varwidth}~\xrfill[0.3ex]{1.5pt}}

\begin{document}

\section{Education}
\lipsum[4]
\section{Education and some other extra~activities}
\lipsum[4]

\end{document}

在此輸入影像描述

如果您要在同一文件中套用兩種樣式,請為每種樣式定義指令並根據需要使用多次它們,以在需要的位置切換:

\documentclass{article}
\usepackage[explicit]{titlesec}
\usepackage{xhfill}
\usepackage{varwidth}
\usepackage{lipsum}% just to generate text for the example

\newcommand\Ruled{%
\titleformat{\section}
  {\normalfont\Large\bfseries}{}{0em}
  {\begin{varwidth}{.7\linewidth}\raggedright##1\end{varwidth}~\xrfill[0.3ex]{1.5pt}}
}
\newcommand\Centered{%
\titleformat{\section}
  {\normalfont\Large\bfseries\filcenter}{}{0em}
  {\xrfill[0.3ex]{1.5pt}~\begin{varwidth}{.75\linewidth}\centering##1\end{varwidth}~\xrfill[0.3ex]{1.5pt}}
}

\begin{document}

\Ruled
\section{Education}
\lipsum[4]
\Centered
\section{Education and some other extra~activities}
\lipsum[4]

\end{document}

在此輸入影像描述

根據您的需求調整設定。我沒有使用小型大寫字母,因為某些字體不支援粗體小型大寫字母。

相關內容