visualize.lco
(已加载命令\LoadLetterOption{visualize}
)指示的引用行顶部与引用行中实际出现的文本之间有一个小间隙。我该如何消除它?
例子:
\documentclass{scrlttr2}
\LoadLetterOption{visualize}
\setkomavar{date}{\fbox{11/01/2011}}
\showfields{address,refline}
\setshowstyle{edges}
\begin{document}
\begin{letter}{Dr.~Leo Lion\\Fordstan University}
\opening{Dear Sir,}
This is a test.
\closing{Sincerely yours}
\end{letter}
\end{document}
答案1
好吧,在文件中visualize.lco
您可以找到命令的定义\showfield@refline}
,以通过边或线显示所用参考线的位置。
在这个定义的末尾,你可以找到命令
\showfield{\useplength{refhpos}}{\useplength{refvpos}}%
{\useplength{refwidth}}{-1.5\baselineskip}%
显示参考线的位置。要更改垂直位置,您需要将第二个参数更改\useplength{refvpos}
为例如1.01\useplength{refvpos}
...
使用以下 MWE
\documentclass{scrlttr2}
\LoadLetterOption{visualize}
\showfields{address,refline}
\setshowstyle{edges}
\makeatletter
\renewcommand*{\showfield@refline}{%
\begingroup
\ifdim\useplength{refwidth}=\z@
\if@refwide
\@setplength{refwidth}{\paperwidth}%
\ifdim \useplength{toaddrhpos}>\z@
\@setplength{refhpos}{\useplength{toaddrhpos}}%
\else
\@setplength[-]{refhpos}{\useplength{toaddrhpos}}%
\fi
\@addtoplength[-2]{refwidth}{\useplength{refhpos}}%
\else
\@setplength{refwidth}{\textwidth}%
\@setplength{refhpos}{\oddsidemargin}%
\@addtoplength{refhpos}{1in}%
\fi
\else\ifdim\useplength{refhpos}=\z@
\begingroup
\setlength\@tempdima{\textwidth}%
\addtolengthplength[-]{\@tempdima}{refwidth}%
\setlength\@tempdimb{\oddsidemargin}%
\addtolength\@tempdimb{1in}%
\setlength{\@tempdimc}{\paperwidth}%
\addtolength{\@tempdimc}{-\textwidth}%
\divide\@tempdimb by 32768\relax
\divide\@tempdimc by 32768\relax
\ifdim\@tempdimc=\z@\else
\multiply\@tempdima by\@tempdimb
\divide\@tempdima by\@tempdimc
\fi
\edef\@tempa{\noexpand\endgroup
\noexpand\@setplength{refhpos}{\the\@tempdima}}%
\@tempa
\fi\fi
\showfield{\useplength{refhpos}}{1.01\useplength{refvpos}}% <=======
{\useplength{refwidth}}{-1.5\baselineskip}%
\endgroup
}
\makeatother
\setkomavar{date}{\fbox{11/01/2011 Qyf}}
%\setkomavar{myref}{201807/Q}
\setkomavar{subject}{Question}
\setkomavar{place}{Capital city}
\begin{document}
\begin{letter}{Dr.~Leo Lion\\Fordstan University}
\opening{Dear Sir,}
This is a test.
\closing{Sincerely yours}
\end{letter}
\end{document}
您将获得以下结果:
但最后我认为这并不重要,因为用于可视化参考线位置的线条或边缘在不改变参考线位置的情况下显示。这只是一个可视化,如果线条/边缘和框之间有一点距离,边缘/线条可以看得更清楚...