scrlttr2
패키지를 통해 사용자 정의 페이지 레이아웃과 함께 KOMA-Script 클래스를 사용하고 있습니다 geometry
. 불행하게도 이로 인해 헤더가 수평으로 오른쪽으로 약간 이동하게 됩니다. MWE는 다음과 같습니다.
\documentclass
%---------------------------------------------------------------------------
[fontsize=11pt,%% Font size
%---------------------------------------------------------------------------
% Type area
paper=a4,%% Sheet size
enlargefirstpage=on,%% Enlarge the first page
pagenumber=headright,%% Page number on the top right of the header
%---------------------------------------------------------------------------
% Layout
headsepline=on,%% Line below the page number
parskip=half,%% Space between paragraphs
%---------------------------------------------------------------------------
% Letterhead and address
fromalign=right,%% Positioning of the letterhead
fromphone=on,%% Phone number in the sender's area
fromrule=off,%% Line below the sender's area (aftername, afteraddress)
fromfax=off,%% Fax number
fromemail=off,%% Mail address
fromurl=off,%% Homepage
fromlogo=off,%% Company logo
addrfield=off,%% Adress field for window envelopes
backaddress=off,%% ... with sender address
subject=beforeopening,%% Positioning of the subject
locfield=narrow,%% Additional field for the sender
foldmarks=off,%% Folding mark
numericaldate=off,%% Numerical date
refline=narrow,%% Spread of the reference line in the type area
firstfoot=false,%
%---------------------------------------------------------------------------
% Formatting
draft=false%% Draft mode
]{scrlttr2}
%---------------------------------------------------------------------------
\usepackage{geometry}
\geometry{a4paper,left=16mm,right=20mm,bottom=25mm,top=23mm,marginparsep=0mm,marginparwidth=0mm,showframe}
%---------------------------------------------------------------------------
\begin{document}
%---------------------------------------------------------------------------
\makeatletter
\@setplength{sigbeforevskip}{0em} % space before signature, in case you write bigger than 12pt :-]
\@setplength{refvpos}{20mm}%\useplength{toaddrvpos}}
\@setplength{firstfootvpos}{285mm} % vertical footer position from top of page
\@setplength{firstheadwidth}{\textwidth}
\makeatother
%---------------------------------------------------------------------------
\setkomavar{signature}{Full name}
%---------------------------------------------------------------------------
\firsthead{
\begin{minipage}{0.5\textwidth}
\fontfamily{lmss}\selectfont\footnotesize
\renewcommand{\baselinestretch}{0.8}
\textbf{Name}\\
Address
\end{minipage}%
\begin{minipage}{0.5\textwidth}
\fontfamily{lmss}\selectfont\footnotesize
\renewcommand{\baselinestretch}{0.8}
\flushright
\begin{tabular}{ll}
Phone & xxx\\
Email & xxx
\end{tabular}
\end{minipage}
\rule{\textwidth}{2pt}
}
\setkomavar{date}{\today}
%---------------------------------------------------------------------------
\begin{letter}{}
\opening{Dear x:}
\closing{Sincerely,}
\end{letter}
\end{document}
결과 스크린샷:
아래 텍스트에 맞게 검은색 규칙을 만들려면 어떻게 해야 합니까?
답변1
음, 귀하의 코드에는 두 가지 문제와 누락된 길이 정의가 있습니다.
- 대신 명령을
\firsthead
사용하십시오\setkomavar{firsthead}{
(경고를 받았을 거라고 확신합니다!?). 명령이 가치가 떨어지기 때문입니다. - 줄의 오른쪽 끝에 텍스트를 정확히 가져오려면
@{}
테이블의 시작 부분에 다음 을 추가해야 합니다 .\begin{tabular}{ll@{}}
- 에서
\@setplength{firstheadhpos}{16mm}
사용했기 때문에 추가해야 합니다 .left=16mm
\geometry
따라서 완전한 코드를 사용하면 다음과 같습니다.
\documentclass
%---------------------------------------------------------------------------
[fontsize=11pt,%% Font size
%---------------------------------------------------------------------------
% Type area
paper=a4,%% Sheet size
enlargefirstpage=on,%% Enlarge the first page
pagenumber=headright,%% Page number on the top right of the header
%---------------------------------------------------------------------------
% Layout
headsepline=on,%% Line below the page number
parskip=half,%% Space between paragraphs
%---------------------------------------------------------------------------
% Letterhead and address
fromalign=right,%% Positioning of the letterhead
fromphone=on,%% Phone number in the sender's area
fromrule=off,%% Line below the sender's area (aftername, afteraddress)
fromfax=off,%% Fax number
fromemail=off,%% Mail address
fromurl=off,%% Homepage
fromlogo=off,%% Company logo
addrfield=off,%% Adress field for window envelopes
backaddress=off,%% ... with sender address
subject=beforeopening,%% Positioning of the subject
locfield=narrow,%% Additional field for the sender
foldmarks=off,%% Folding mark
numericaldate=off,%% Numerical date
refline=narrow,%% Spread of the reference line in the type area
firstfoot=false,%
%---------------------------------------------------------------------------
% Formatting
draft=false%% Draft mode
]{scrlttr2}
%---------------------------------------------------------------------------
\usepackage{geometry}
\geometry{a4paper,left=16mm,right=20mm,bottom=25mm,top=23mm,marginparsep=0mm,marginparwidth=0mm,showframe}
%---------------------------------------------------------------------------
\begin{document}
%---------------------------------------------------------------------------
\makeatletter
\@setplength{sigbeforevskip}{0em} % space before signature, in case you write bigger than 12pt :-]
\@setplength{refvpos}{20mm}%\useplength{toaddrvpos}}
\@setplength{firstfootvpos}{285mm} % vertical footer position from top of page
\@setplength{firstheadwidth}{\textwidth}
\@setplength{firstheadhpos}{16mm} % <===================================
\makeatother
%---------------------------------------------------------------------------
\setkomavar{signature}{Full name}
%---------------------------------------------------------------------------
\setkomavar{firsthead}{% <==============================================
\begin{minipage}{0.5\textwidth}
\fontfamily{lmss}\selectfont\footnotesize
\renewcommand{\baselinestretch}{0.8}
\textbf{Name}\\
Address
\end{minipage}%
\begin{minipage}{0.5\textwidth}
\fontfamily{lmss}\selectfont\footnotesize
\renewcommand{\baselinestretch}{0.8}
\flushright
\begin{tabular}{ll@{}} % <==============================================
Phone & xxx\\
Email & xxx
\end{tabular}
\end{minipage}
\rule{\textwidth}{2pt}%
}
\setkomavar{date}{\today}
%---------------------------------------------------------------------------
\begin{letter}{}
\opening{Dear x:}
\closing{Sincerely,}
\end{letter}
\end{document}
결과는 다음과 같습니다.
답변2
기본적으로 의사 길이 firstheadhpos
는 \maxdimen
. 이로 인해 헤더가 용지 중앙에 수평으로 배치됩니다. 그러나 텍스트 영역이 페이지의 수평 중앙에 있지 않습니다. 따라서 의사 길이를 firstheadhpos
왼쪽 여백과 동일한 값으로 설정해야 합니다 .
\documentclass[
fontsize=11pt,
parskip=half,
addrfield=off,
firstfoot=false
]{scrlttr2}
\usepackage{geometry}
\newcommand*\myleftmargin{16mm}% <- added
\geometry{
left=\myleftmargin,% <- changed
right=20mm,bottom=25mm,top=23mm,marginparsep=0mm,marginparwidth=0mm,showframe}
\setplength{sigbeforevskip}{0em}
\setplength{refvpos}{20mm}
\setplength{firstfootvpos}{285mm}
\setplength{firstheadwidth}{\textwidth}
\setplength{firstheadhpos}{\myleftmargin}% <- added
%---------------------------------------------------------------------------
\begin{document}
\setkomavar{signature}{Full name}
\setkomavar{firsthead}{% <- remove spurious space and changed syntax
\begin{minipage}{0.5\textwidth}
\fontfamily{lmss}\selectfont\footnotesize
\renewcommand{\baselinestretch}{0.8}
\textbf{Name}\\
Address
\end{minipage}%
\begin{minipage}{0.5\textwidth}
\fontfamily{lmss}\selectfont\footnotesize
\renewcommand{\baselinestretch}{0.8}
\raggedleft
\begin{tabular}{ll@{}}% <- changed to align the last column with the rule
Phone & xxx\\
Email & xxx
\end{tabular}%
\end{minipage}
\par
\rule{\textwidth}{2pt}%
}
\begin{letter}{}
\opening{Dear x:}
\closing{Sincerely,}
\end{letter}
\end{document}
결과:
관련 없는 내용을 제거하고 firsthead
변수에 대한 uptodate 구문을 사용하기 위해 몇 가지 변경 사항을 추가했습니다. 최신 KOMA-Script 버전(현재 3.26)을 사용하면 \setplength
대신 \@setplength
.