更改 Minipage 中的字体样式

更改 Minipage 中的字体样式

我正在尝试在我的文档中生成一个引文,并希望使用不同的字体样式。

为了实现这一点,我有一个包含 minipage 的 wrapfig 环境。我想在此 minipage 中设置不同的字体样式。

下面是一个 MWE;它看起来是这样的。例如,我希望红色引文采用 Cabin 字体。

enter image description here

\documentclass[11pt]{article}

\usepackage{float}                      % Define tables and floating elements
\usepackage{flafter}                    % Never put floats before their references
\usepackage{floatflt}                   % wrap text around floats
\usepackage{wrapfig}                    % wrap text around figures
\usepackage[usenames,dvipsnames]{color}                     % Enable colors
\usepackage{lipsum}                     % Lorem Ipsum, for placeholder text.

\usepackage{cabin}
\usepackage{setspace}
\usepackage[T1]{fontenc}

\begin{document}
\section{My Section Heading}\label{sec:mysect}

    %%% If the pull quote comes immediately after a section heading, the next three lines are needed, as well as the line after the paragraph
    \newlength{\tempintextsep}
    \setlength{\tempintextsep}{\intextsep}
    \setlength{\intextsep}{0pt}
    %%
    \begin{wrapfigure}[20]{r}{2.2in}
    \textcolor{red}{
    \setlength{\abovedisplayskip}{0pt}
    $$
    \left\{\;\;\;
    \begin{minipage}{1.65in}
    \centering
    \begingroup
    \fontfamily{Cabin}\selectfont
    \huge
    \textrm{
    \linespread{2}
    Among all of the important things that were ever important, this thing is the most important of all of them; or at least the most important of all of them that appear on this page.
    }
    \endgroup
    \end{minipage}\;\;\;
    \right\}
    $$
    }
    \end{wrapfigure}

    \lipsum[1-4]
    %% if the pullquote came after a section heading, use the following line
    \setlength{\intextsep}{\tempintextsep}

\end{document}

答案1

请注意,该软件包cabin仅更改了无衬线字体系列。因此,您只需将其替换\textrm\textsf并删除以下行即可

\fontfamily{Cabin}\selectfont

完成 MWE(请注意,我刚刚将wrapfig行数从 20 更改为 22,没有像 Dustin 建议的那样进行其他更改)

\documentclass[11pt]{article}

\usepackage{float}                      % Define tables and floating elements
\usepackage{flafter}                    % Never put floats before their references
\usepackage{floatflt}                   % wrap text around floats
\usepackage{wrapfig}                    % wrap text around figures
\usepackage[usenames,dvipsnames]{color}                     % Enable colors
\usepackage{lipsum}                     % Lorem Ipsum, for placeholder text.

\usepackage{cabin}
\usepackage{setspace}
\usepackage[T1]{fontenc}

\begin{document}
\section{My Section Heading}\label{sec:mysect}

    %%% If the pull quote comes immediately after a section heading, the next three lines are needed, as well as the line after the paragraph
    \newlength{\tempintextsep}
    \setlength{\tempintextsep}{\intextsep}
    \setlength{\intextsep}{0pt}
    %%
    \begin{wrapfigure}[22]{r}{2.2in}
    \textcolor{red}{
    \setlength{\abovedisplayskip}{0pt}
    $$
    \left\{\;\;\;
    \begin{minipage}{1.65in}
    \centering
    \begingroup
    \huge
    \linespread{2}
    \textsf{%
    Among all of the important things that were ever important, this thing is the most important of all of them; or at least the most important of all of them that appear on this page.
    }
    \endgroup
    \end{minipage}\;\;\;
    \right\}
    $$
    }
    \end{wrapfigure}

    \lipsum[1-4]
    %% if the pullquote came after a section heading, use the following line
    \setlength{\intextsep}{\tempintextsep}

\end{document} 

输出

enter image description here

答案2

你的主要错误是在这里

\begingroup
\fontfamily{Cabin}\selectfont
\huge
\textrm{
\linespread{2}
Among all of the important things that were ever important, this thing is the most important of all of them; or at least the most important of all of them that appear on this page.
}
\endgroup

每当字体大小发生变化时,您必须始终确保段落末尾在同一范围内,否则您将得到大文本,并将其设置为较小的基线,并且行距会非常不均匀。无论如何,您不需要分组,因为 minipage 会为您分组

 \begin{minipage}{1.65in}
\centering
\fontfamily{Cabin}\huge
\linespread{2}
Among all of the important things that were ever important, this thing is the most important of all of them; or at least the most important of all of them that appear on this page.
\end{minipage}

只要你\fontfamily{Cabin}设置了

相关内容