
LaTeX で、右揃えの見出しの真下にテキストを中央揃えにするにはどうすればよいでしょうか。これまでの私の試みの方がわかりやすいかもしれません。
\documentclass{article}
\usepackage[ hmargin = 1in, vmargin = 1in ]{geometry}
\setlength{\parindent}{0pt}
\usepackage{showframe}
\begin{document}
\begin{minipage}{.6\linewidth}\huge Some Heading\end{minipage}
\hfill
\begin{minipage}{.33\linewidth}
\raggedleft {\huge Another Heading} \\
\centering \today
\end{minipage}
\end{document}
問題は、minipage
幅の引数が必要なので、2 行目を完全に中央に配置する唯一の方法は、レンダリング後の見出しの正確な幅を (事前に) 推測することです。もっと良い方法はありますか?
答え1
\documentclass{article}
\usepackage[ hmargin = 1in, vmargin = 1in ]{geometry}
\setlength{\parindent}{0pt}
\usepackage{showframe}
\begin{document}
\begin{minipage}[t]{.6\linewidth}\huge Some Heading\end{minipage}
\hfill
\begin{tabular}[t]{@{}c@{}}
\huge Another Heading \\
\today
\end{tabular}
\end{document}
答え2
David のtabular
解決策はうまく機能しますが、私は多くの場合、 を使用して希望の幅のボックスを作成し、その「ボックス」内でテキストを揃えます。以下では、 と同じ幅のボックス内でテキストをenter、ight、 eftで揃える\makebox
方法を示します。c
r
l
\widthof{\huge Another Heading}
ノート:
- マクロ
\widthof
はそのcalc
包み。
コード:
\documentclass{article}
\usepackage[ hmargin = 1in, vmargin = 1in ]{geometry}
\setlength{\parindent}{0pt}
\usepackage{showframe}
\usepackage{calc}
\begin{document}
\begin{minipage}{.3\linewidth}\huge Some Heading\end{minipage}
\hfill
\begin{minipage}{.4\linewidth}
\raggedleft {\huge Another Heading} \\
\makebox[\widthof{\huge Another Heading}][c]{\today} \\
\makebox[\widthof{\huge Another Heading}][r]{\today} \\
\makebox[\widthof{\huge Another Heading}][l]{\today}
\end{minipage}
\end{document}
答え3
積み重ねてください。
\documentclass{article}
\usepackage[ hmargin = 1in, vmargin = 1in ]{geometry}
\setlength{\parindent}{0pt}
\usepackage{showframe}
\usepackage{stackengine}
\begin{document}
{\huge Some Heading}
\hfill
\stackunder[2pt]{\huge Another Heading}{\today}
\end{document}