我在为小页面中的部分标题设置适当的填充时遇到了一些麻烦。
\documentclass{article}
\usepackage[explicit]{titlesec}
\newcommand\Vhrulefill{\leaders\hrule height 0.7ex depth \dimexpr0.4pt-0.7ex\hfill\kern0pt}
\titleformat{\section}{\bfseries\large}{}{0pt}{\noindent\Vhrulefill~#1~\Vhrulefill}
\begin{document}
\begin{minipage}[t]{0.45\textwidth}
\section{Introduction}
Some content for the first section
\section{One More Section}
\begin{itemize}
\item Item 1
\item Item 2
\end{itemize}
\section{Another Section}
Some text outside of a list here
\section{Last section}
\begin{itemize}
\item One here
\item One more
\end{itemize}
\end{minipage}%
\hfill\vline\hfill
\begin{minipage}[t]{0.45\textwidth}
\section{Introduction}
Some content for the first section
\section{One More Section}
\begin{itemize}
\item Item 1
\item Item 2
\end{itemize}
\section{Another Section}
Some text outside of a list here
\section{Last section}
\begin{itemize}
\item One here
\item One more
\end{itemize}
\end{minipage}%
\end{document}
“再多一个部分”之前的间距太小,而之后的间距太大。
当我尝试使用 进行调整时\titlespacing
,它不会影响所有部分
答案1
以下是 3 种解决方案
\documentclass{article}
\usepackage[explicit]{titlesec}
\usepackage{multicol}
\newcommand\Vhrulefill{\leaders\hrule height 0.7ex depth \dimexpr0.4pt-0.7ex\hfill\kern0pt}
\titleformat{\section}{\bfseries\large}{}{0pt}{\noindent\Vhrulefill~#1~\Vhrulefill}
\setlength\columnseprule{.4pt}
%\setlength\columnsep{12pt}
\begin{document}
\begin{multicols}{2}
\section{Introduction}
Some content for the first section
\section{One More Section}
\begin{itemize}
\item Item 1
\item Item 2
\end{itemize}
\section{Another Section}
Some text outside of a list here
\section{Last section}
\begin{itemize}
\item One here
\item One more
\end{itemize}
%\columnbreak
\section{Introduction}
Some content for the first section
\section{One More Section}
\begin{itemize}
\item Item 1
\item Item 2
\end{itemize}
\section{Another Section}
Some text outside of a list here
\section{Last section}
\begin{itemize}
\item One here
\item One more
\end{itemize}
\end{multicols}
\end{document}
\documentclass{article}
\usepackage[explicit]{titlesec}
\newcommand\Vhrulefill{\leaders\hrule height 0.7ex depth \dimexpr0.4pt-0.7ex\hfill\kern0pt}
\titleformat{\section}{\bfseries\large}{}{0pt}{\noindent\Vhrulefill~#1~\Vhrulefill}
\begin{document}
\parbox[t]{0.45\textwidth}{%
\section{Introduction}
Some content for the first section
\section{One More Section}
\begin{itemize}
\item Item 1
\item Item 2
\end{itemize}
\section{Another Section}
Some text outside of a list here
\section{Last section}
\begin{itemize}
\item One here
\item One more
\end{itemize}
}%
\hfill\vline\hfill
\parbox[t]{0.45\textwidth}{%
\section{Introduction}
Some content for the first section
\section{One More Section}
\begin{itemize}
\item Item 1
\item Item 2
\end{itemize}
\section{Another Section}
Some text outside of a list here
\section{Last section}
\begin{itemize}
\item One here
\item One more
\end{itemize}
}
\end{document}
\documentclass{article}
\usepackage[explicit]{titlesec}
\newcommand*\thirdoffive[5]{#3}
\makeatletter
\newcommand*\mt{\vskip-\expandafter\thirdoffive\ttls@section\ }
\makeatother
\newcommand\Vhrulefill{\leaders\hrule height 0.7ex depth \dimexpr0.4pt-0.7ex\hfill\kern0pt}
\titleformat{\section}{\bfseries\large}{}{0pt}{\noindent\Vhrulefill~#1~\Vhrulefill}
\begin{document}
\begin{minipage}[t]{0.45\textwidth}\mt
\section{Introduction}
Some content for the first section
\section{One More Section}
\begin{itemize}
\item Item 1
\item Item 2
\end{itemize}
\section{Another Section}
Some text outside of a list here
\section{Last section}
\begin{itemize}
\item One here
\item One more
\end{itemize}
\end{minipage}%
\hfill\vline\hfill
\begin{minipage}[t]{0.45\textwidth}\mt
\section{Introduction}
Some content for the first section
\section{One More Section}
\begin{itemize}
\item Item 1
\item Item 2
\end{itemize}
\section{Another Section}
Some text outside of a list here
\section{Last section}
\begin{itemize}
\item One here
\item One more
\end{itemize}
\end{minipage}
\end{document}