![如何将文本垂直居中在两条水平虚线之间](https://linux22.com/image/419998/%E5%A6%82%E4%BD%95%E5%B0%86%E6%96%87%E6%9C%AC%E5%9E%82%E7%9B%B4%E5%B1%85%E4%B8%AD%E5%9C%A8%E4%B8%A4%E6%9D%A1%E6%B0%B4%E5%B9%B3%E8%99%9A%E7%BA%BF%E4%B9%8B%E9%97%B4.png)
MWE 基本上是不言自明的。我想创建一个产生给定输出的命令。该命令应采用强制参数,指定文本上方/下方的空间量。文本是小写小型大写字母。
\documentclass[11pt]{article}
\usepackage{graphicx}
\newcommand\oblongdot{\protect\resizebox{0.75pt}{3pt}{$\cdot$}}
\makeatletter
\newcommand\cdotfill{%
\leavevmode\cleaders\hb@[email protected]{\hss\oblongdot\hss}\hfill\kern\z@
}
\makeatother
\newcommand\cdotrule{\makebox[4in]\cdotfill}
\begin{document}
\begin{center}
\cdotrule \\
\textsc{\LARGE vertically centered text} \\
\cdotrule
\end{center}
\end{document}
灵感来自
答案1
这些点不是垂直居中的。您可以使用框\vcenter
来对齐材料。您可以修改\oblongdot
宏,如下所示:
\newcommand\oblongdot{\protect$\vcenter{\resizebox{0.75pt}{3pt}{$\cdot$}}$}
\documentclass[11pt]{article}
\usepackage{graphicx}
\newcommand\oblongdot{\protect$\vcenter{\resizebox{0.75pt}{3pt}{$\cdot$}}$}
\makeatletter
\newcommand\cdotfill{%
\leavevmode\cleaders\hb@[email protected]{\hss\oblongdot\hss}\hfill\kern\z@
}
\makeatother
\newcommand\cdotrule{\makebox[4in]\cdotfill}
\begin{document}
\begin{center}
\cdotrule \\
\textsc{\LARGE vertically centered text} \\
\cdotrule
\end{center}
\end{document}
答案2
我无法让你的宏与 hrule 一起工作——正如这里定义的——
https://tex.stackexchange.com/a/389279/197451
\documentclass[11pt]{article}
\usepackage{cellspace, tabularx, booktabs}
\usepackage[x11names]{xcolor}
\usepackage{garamondx}
\addparagraphcolumntypes{X}
\begin{document}
\begin{titlepage}
\setlength{\cellspacetoplimit}{11pt}
\setlength{\cellspacebottomlimit}{12pt}
\begin{center}
\huge \textit{Edward Lear}\vspace{10ex}
\Huge\bfseries
\begin{tabularx}{\linewidth}{S{>{\centering\arraybackslash}X}}
\toprule
\color{IndianRed3} The Pobble Who Has No Toes \\
\bottomrule
\end{tabularx}
\end{center}
\end{titlepage}
\end{document}