问题:
我在对齐图标时遇到问题,description
因此它们无法与右侧对应文本的顶部相匹配。
最小工作示例(MWE):
\documentclass{scrreprt}
\usepackage[swedish]{babel}
\usepackage[medfamily,textosf,mathlf,mnsy,amsbb,mixedgreek,minionint,openg,footnotefigures]{MinionPro}
\usepackage[onlytext,medfamily,osf]{MyriadPro}
\usepackage{fontawesome}
\usepackage[shortlabels]{enumitem}
\usepackage{calc}
\usepackage{blindtext}
\begin{document}
\newlength{\introicons}
\setlength{\introicons}{\widthof{\faEnvelopeO}}
\addtolength{\introicons}{\labelsep}
\SetLabelAlign{CenterWithParen}{\makebox[\introicons]{#1}}
\begin{description}[
itemsep=0.75em,
topsep=0pt,
parsep=0pt,
partopsep=0pt,
labelwidth=\introicons,
itemindent=0cm,
leftmargin=!,
rightmargin=0cm,
align=CenterWithParen
]
\item[\centering \large \faHtml5] \blindtext[1]
\item[\centering \faEnvelopeO] \blindtext[1]
\item[\centering \large \faMobilePhone] \blindtext[1]
\end{description}
\end{document}
视觉示例:
请注意,HTML5 和手机图标没有与文本顶部对齐,而电子邮件图标则与文本顶部对齐。
答案1
这里我使用scalerel
来使图标成为大写字母的垂直布局X
。(我还\centering
从图标调用中删除了它,因为它似乎是多余的)。请注意,由于scalerel
默认情况下在数学模式下处理参数,因此使用$
分隔符实际上会强制在文本模式下评估图标。 的实例\large
也被删除了,因为scalerel
不需要它们缩放到指定的大小。
修订的解决方案(固定宽度,可变高度,但图标顶部对齐)
\documentclass{scrreprt}
%\usepackage[swedish]{babel}
%\usepackage[medfamily,textosf,mathlf,mnsy,amsbb,mixedgreek,minionint,openg,footnotefigures]{MinionPro}
%\usepackage[onlytext,medfamily,osf]{MyriadPro}
\usepackage{fontawesome}
\usepackage[shortlabels]{enumitem}
\usepackage{calc}
\usepackage{blindtext}
\usepackage{scalerel,graphicx,stackengine}
\def\mydim{15pt}
\newcommand\scalewd[2][\mydim]{%
\fboxsep=\fboxrule%
\setbox0=\hbox{X}%
\smash{\belowbaseline[-\ht0]{%
\rotatebox[origin=right]{-90}{%
\scaleto{\rotatebox[origin=right]{90}{\belowbaseline[0pt]{#2}}}{#1}%
}%
}}%
}
\begin{document}
\newlength{\introicons}
\setlength{\introicons}{\widthof{\faEnvelopeO}}
\addtolength{\introicons}{\labelsep}
\SetLabelAlign{CenterWithParen}{\makebox[\introicons]{#1}}
\begin{description}[
itemsep=0.75em,
topsep=0pt,
parsep=0pt,
partopsep=0pt,
labelwidth=\introicons,
itemindent=0cm,
leftmargin=!,
rightmargin=0cm,
align=CenterWithParen
]
\item[\scalewd{\faHtml5}] \blindtext[1]
\item[\scalewd{\faEnvelopeO}] \blindtext[1]
\item[\scalewd{\faMobilePhone}] \blindtext[1]
\end{description}
\clearpage\def\mydim{20pt}
\begin{description}[
itemsep=0.75em,
topsep=0pt,
parsep=0pt,
partopsep=0pt,
labelwidth=\introicons,
itemindent=0cm,
leftmargin=!,
rightmargin=0cm,
align=CenterWithParen
]
\item[\scalewd{\faHtml5}] \blindtext[1]
\item[\scalewd{\faEnvelopeO}] \blindtext[1]
\item[\scalewd{\faMobilePhone}] \blindtext[1]
\end{description}
\end{document}
默认图标宽度为 15pt
20 pt 图标宽度
原始解决方案(固定高度,可变宽度的图标)
\documentclass{scrreprt}
%\usepackage[swedish]{babel}
%\usepackage[medfamily,textosf,mathlf,mnsy,amsbb,mixedgreek,minionint,openg,footnotefigures]{MinionPro}
%\usepackage[onlytext,medfamily,osf]{MyriadPro}
\usepackage{fontawesome}
\usepackage[shortlabels]{enumitem}
\usepackage{calc}
\usepackage{blindtext}
\usepackage{scalerel}
\begin{document}
\newlength{\introicons}
\setlength{\introicons}{\widthof{\faEnvelopeO}}
\addtolength{\introicons}{\labelsep}
\SetLabelAlign{CenterWithParen}{\makebox[\introicons]{#1}}
\begin{description}[
itemsep=0.75em,
topsep=0pt,
parsep=0pt,
partopsep=0pt,
labelwidth=\introicons,
itemindent=0cm,
leftmargin=!,
rightmargin=0cm,
align=CenterWithParen
]
\item[\scalerel*{$\faHtml5$}{X}] \blindtext[1]
\item[\scalerel*{$\faEnvelopeO$}{X}] \blindtext[1]
\item[\scalerel*{$\faMobilePhone$}{X}] \blindtext[1]
\end{description}
\end{document}