我正在看第一个“字母类”示例LaTeX/信件 - 维基教科书,为开放世界开放书籍我想要做的是使用\newcommand
- 比如\insertbox
- 它将插入到\adress
语句中的某个位置,例如:
...
\address{\insertbox{}21 Bridge Street \\ Smallville \\ Dunwich DU3 4WE}
...
...在 的定义中\insertbox
,有四行文本(例如,21 Bridge Street \\ Smallville \\ extra line \\ Dunwich DU3 4WE
),其宽度为 2.5 厘米;位于地址行的左侧,并且(左侧)框文本的第一行与地址文本的第一行对齐。
推荐采用什么方法来做到这一点?
PS:作为参考,我将以下示例的页面图像热链接起来:
编辑:带有红色轮廓的框的位置是我想要实现的:
里面的文字毫无意义(我只是快速复制粘贴了图片的一部分gimp
) - 但这正是应该通过\insertbox
命令指定的。
答案1
这可能就是你想要的:
...
\newcommand{\insertbox}[1]{%
\llap{\smash{\parbox[t]{2.5cm}{#1}}}%
}
...
\address{\insertbox{hello world \\ some text \\ more text}%
21 Bridge Street \\ Smallville \\ Dunwich DU3 4WE}
\llap
允许零宽度框左重叠,同时\smash
确保换行不会影响命令其余部分的换行\address
。否则,将使用 each inSmallville
向下推。最后,提供一个 2.5 厘米宽(段落/左对齐)框,在顶部对齐。\\
\insertbox
\parbox[t]{2.5cm}
[t]
答案2
这是基于我的adjustbox
包的解决方案。我还添加了红色边框本身。如果您不想要它,只需移除cfbox=red
密钥和包即可。xcolor
我\insertbox
有一个参数来指定宽度。
\documentclass{letter}
\usepackage{hyperref}
\usepackage{adjustbox}
\usepackage{xcolor}
\signature{Joe Bloggs}
\newcommand\insertbox[1]{%
\adjustbox{minipage=[t]{#1},cfbox=red,set height=0pt,set depth=0pt,lap=-\width-10pt}%
}
\address{\insertbox{7.75em}{That said, allow end of providing only if you agree and post it back}21 Bridge Street \\ Smallville \\ Dunwich DU3 4WE}
\begin{document}
\begin{letter}{Director \\ Doe \& Co \\ 35 Anthony Road
\\ Newport \\ Ipswich IP3 5RT}
\opening{Dear Sir or Madam:}
I am writing to you on behalf of the Wikipedia project (http://www.wikipedia.org/),
an endeavour to build a fully-fledged multilingual encyclopaedia in an entirely
open manner, to ask for permission to use your copyrighted material.
% The \ldots command produces dots in a way that will not upset
% the typesetting of the document.
\ldots
That said, allow me to reiterate that your material will be used to the noble end of
providing a free collection of knowledge for everyone; naturally enough, only if you
agree. If that is the case, could you kindly fill in the attached form and post it
back to me? We shall greatly appreciate it.
Thank you for your time and consideration.
I look forward to your reply.
\closing{Yours Faithfully,}
\ps{P.S. You can find the full text of GFDL license at
\url{http://www.gnu.org/copyleft/fdl.html}.}
\encl{Copyright permission form}
\end{letter}
\end{document}
从技术上讲,这与 Werner 的答案并没有太大区别,只是用作adjustbox
不同修改的包装器。