beamer 中的公式实现下划线的标识

发布于 2023-05-23 08:44:40 浏览次数 193


因此,我编写了一个包装器 \myul,在这种情况下基于上下文(数学模式或普通模式)选择一种技术来使用。通过可选参数,您可以手动指定颜色、厚度、深度和技术。您可以使用命令 \setmyul 为当前组中的整个设置更改这些设置。对于某些选项,数学模式或文本模式可能需要指定不同的值。有关更多详细信息,请参见代码中的注释。




% ---------- key=value options ----------



    % thickness of the rule
    % distance from baseline where to place the top of the rule
        math depth=#1,
        text depth=#1,
    math depth/.code={%
    text depth/.code={%
    % distance from bottom edge of box where to place the top of the rule
    % works only with command = box
        math distance=#1,
        text distance=#1,
    math distance/.code={%
    text distance/.code={%
    % color in which to draw the rule (not the text)
    % which implementation technique to use
        text command=#1,
        math command=#1,
    text command/.is choice,
    text command/soul/.code     ={\let\@myul@text@do=\@myul@soul},
    text command/box/.code      ={\let\@myul@text@do=\@myul@box},
    text command/primitive/.code={\let\@myul@text@do=\@myul@primitive},
    math command/.is choice,
    math command/soul/.code     ={\let\@myul@math@do=\@myul@soul},
    math command/box/.code      ={\let\@myul@math@do=\@myul@box},
    math command/primitive/.code={\let\@myul@math@do=\@myul@primitive},
    % what to do if key is none of the above defined
        % only process keys for which no full path has been provided
        % TikZ documentation, page 900
            \def\pgfutilnext{\pgfkeysvalueof {/handlers/.unknown/.@cmd}#1\pgfeov}%

% ---------- user interface ----------


            \expandafter \@myul@math@do
            \expandafter \@myul@text@do

% for auto completion in TeXstudio

% ---------- using soul package ----------
% based on soul package
% supports line break
% the text to be underlined can *not* be arbitrary TeX code
% see soul package documentation [November 17, 2003] page 5
% does *not* work in math mode


% ---------- using boxes ----------
% based on:
% does *not* support line breaks


        \sbox\@myul@box@tmpbox{$\m@th \currentmathstyle #1$}%
            % \SOUL@ulcolor = \textcolor{<color>}

% ---------- using TeX primitive ----------
% In plain TeX \underline is a primitive 
% which can be used in math mode only.
% In LaTeX \underline is overridden 
% so that it can be used outside of math mode, too.
% Either way, it does *not* support line breaks.
% Thickness and depth are *not* freely adjustable.
% thickness = $\theta$, distance to underline = $3\theta$
% where $\theta=\xi_8$ default rule thickness
% [The TeXbook, page 443, rule 10]
% default rule thickness can be changed with:
% \fontdimen8\textfont3=5pt
% default rule thickness is 0.4pt
% Changing the default rule thickness 
% changes the thickness of fraction bars, too.
% Therefore this command ignores the thickness and depth options.
% You should avoid this method to avoid inconsistencies.

% based on
    % colored underline:
    % transparent underline:
    % switch between colored and transparent: sections 9.3 and 9.6.1
    % \SOUL@ulcolor = \textcolor{<color>}


% ---------- default settings ----------

    text command=soul,
    math command=box,

% ---------- test ----------

\setmyul{math distance=.5ex}


% based on


\begin{frame}{Coloured Underlining}

    Different parts of text can be underlined, using colours such as \myul[color=green]{green}, \myul[red]{red}. 
    The \myul[thickness=2pt]{thickness} of the underline can be set.
    Additionally, the \myul[depth=1pt]{depth} of the underline can be set, too.


    Underlining is consistent with \myul<2->{Beamer} \myul<3->[thickness=5pt]{overlays}.


    Underlining works as well in equations such
    as $f(x) = \lambda\, e^x$ and

        \mu = \myul<2->[red]{\frac{1}{2} \int_0^1 x \, f_{P_{ij}}(x) \dif x} 
            + \frac{1}{2} \int_0^1 f_{P_{ij}}(x) 
              \int_0^1 \myul<3->[red, thickness=5pt]{y \,f_{P_{ji}\vert P_{ij}}(y \mid x)} \dif y \dif x.


    Underlining longer expressions doesn't lead to \myul{lines breaking early, but rather the underline} stretches across two lines of text.




0 条评论