
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
너비 인수가 필요하므로 두 번째 줄을 완벽하게 중앙에 배치할 수 있는 유일한 방법은 제목이 렌더링된 후의 정확한 너비를 (미리) 추측하는 것입니다. 더 좋은 방법이 있나요?
답변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
종종 를 사용합니다 . 아래에서는 다음과 같은 너비의 상자 내에서 텍스트를 입력, 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}