制作非方形大片

制作非方形大片

https://tex.stackexchange.com/a/552557/13492\bigtimes,展示了一种创建符号(用于家族的笛卡尔积)和\bigplus符号(用于家族的笛卡尔和)的方法。

问题:

  1. 如何修改才能\bigtimes使不是有一个方形的形状,也就是说,两个笔划不是以直角交叉,从而使符号的宽度小于其高度。

  2. 答案https://tex.stackexchange.com/a/552769/13492包括一个\scalebox水平缩放因子\scalefactor,其值基本上是根据目标符号进行硬编码的。是否可以\scalefactor修改代码以包含一个额外的参数,默认值为 1,作为水平缩放因子?

  3. 考虑到预期用途,两个符号都采用下标和/或上标进行索引,是否不需要\DeclareMathOperator\mathop?如果是,应如何纳入;如果不是,为什么不呢?

来源:代码来自https://tex.stackexchange.com/a/552557/13492由我尝试使用两种不同的注释掉的方法进行补充,以实现目标 1。

\documentclass[fleqn]{article}
\usepackage{amsmath,pict2e}
\usepackage{iftex}

\ifTUTeX
  \usepackage{unicode-math}
  \setmainfont{TeX Gyre Termes}[Scale=1.0]
  \setmathfont{TeX Gyre Termes Math}
\else
  \usepackage{newtxtext,newtxmath}
\fi

\makeatletter
\newcommand{\my@big}[1]{%
  \mathop{\vphantom{\sum}\mathpalette\my@makebig{#1}}\slimits@
}
\AtBeginDocument{%
  \DeclareRobustCommand{\bigplus}{\DOTSB\my@big\my@plus}%
  \DeclareRobustCommand{\bigtimes}{\DOTSB\my@big\my@times}%
}
\newcommand{\my@makebig}[2]{%
  \vcenter{%
    \sbox\z@{$\m@th#1\sum$}%
    \setlength{\unitlength}{0.9\dimexpr\ht\z@+\dp\z@}%
    \hbox{\kern0.1\wd\z@\my@draw{#1}{#2}\kern0.1\wd\z@}%
  }%
}
\newcommand{\my@draw}[2]{%
  \begin{picture}(1,1)
    \linethickness{%
      \ifx#1\displaystyle 1.2\fontdimen8\textfont3\else
      \ifx#1\textstyle 1.1\fontdimen8\textfont3\else
      \ifx#1\scriptstyle1\fontdimen8\scriptfont3\else
      1\fontdimen8\scriptscriptfont3\fi\fi\fi
    }%
    #2
  \end{picture}%
}
\newcommand{\my@plus}{%
  \roundcap
  \Line(0.5,0)(0.5,1)
  \Line(0,0.5)(1,0.5)
}
\newcommand{\my@times}{%
  \roundcap
  \Line(0,0)(1,1)
  \Line(0,1)(1,0)
}

%% Attempt #1 to try to reshape \bigtimes...
%% ...leaves too much space after \bigtimes...
%% ... and displaystyle puts sub- & super-scripts off-center
%\newcommand{\my@times}{%
%  \roundcap
%  \Line(0,0)(0.75,1)
%  \Line(0,1)(0.75,0)
%}

%% Attempt #2 to reshape \bigtimes, using \scalebox instead ...
%% ... makes lines too thin and leaves too much space after \bigtmies...
%% ... and displaystyle puts sub- & super-scripts off-center:
%\newcommand{\my@@times}{%
%  \roundcap
%  \Line(0,0)(1,1)
%  \Line(0,1)(1,0)
%}
%\usepackage{graphicx}
%\newcommand{\my@times}{%
%  \scalebox{0.85}[1]{\my@@times}%
%}

\makeatother

\begin{document}

In-line $
\bigplus_{i\in I} X_i  = \bigtimes_{j\in J} Y_i = \bigcup_{i\in I} Z_{i} =  \bigcap_{n\in I} Z_{i} 
$ here.
\[
\bigplus_{i\in I} X_i = \bigtimes_{j\in J} Y_i = \bigcup_{i\in I} Z_i =  \bigcap_{n\in I} Z_{i} 
\]

In-line $
\bigplus_{i=0}^{\infty} X_i  = \bigtimes_{j=0}^{\infty} Y_i = \bigcup_{i=0}^{\infty} Z_{i} =  \bigcap_{n=0}^{\infty} Z_{i} 
$ here.
\[
\bigplus_{i=0}^{\infty} X_i = \bigtimes_{j=0}^{\infty} Y_i = \bigcup_{i=0}^{\infty} Z_i =  \bigcap_{n=0}^{\infty} Z_{i} 
\]
\end{document}

输出:显示的所有输出都是使用 XeLaTeX 生成的;如果使用 pdfLaTeX,结果会类似。

首先是使用原始代码的输出https://tex.stackexchange.com/a/552557/13492

原创方形大时代

其次,如果使用 my 的输出Attempt 1,则会在内联模式下留下太多空间\bigtimes,并在显示模式下将子标和上标置于中心之外:

尝试 #1 bigtimes

第三,如果使用 my 的输出Attempt 2,也会在内联模式下留下太多空间\bigtimes,并在显示模式下使子标和上标偏离中心:

使用 scalebox 进行第二次尝试

答案1

通过创建单独的\my@narrowbig\my@narrowmakebig、 和\my@narrowdraw\my@narrowtimes命令,使用 0.75 宽和 1 高的绘图画布,我可以得到一个或多或少适合笛卡尔积的非平方\bigtimes运算符号。同样,也可以得到一个\bigbox盒子积的运算符号(在拓扑意义上)。

结果:

非正方形、修正、bigtimes 和 bigbox

代码如下所示。

投诉:

  1. 在屏幕上查看时,新符号的笔画看起来不错;但在打印时,与 相比, 、 和 的笔画似乎太\bigtimes\bigsum了一点。\bigbox\bigcup\bigcap该如何修复?
  2. 必须创建两组命令 — — 一组用于新的操作\bigsum符,另一组用于其他新的操作符,这似乎是一种极大的代码浪费。有没有什么方法可以合并这些代码?

修改后的源码:

\documentclass[fleqn]{article}
\usepackage{amsmath,pict2e}
\usepackage{iftex}

\ifTUTeX
  \usepackage{unicode-math}
  \setmainfont{TeX Gyre Termes}[Scale=1.0]
  \setmathfont{TeX Gyre Termes Math}
\else
  \usepackage{newtxtext,newtxmath}
\fi

\makeatletter
\newcommand{\my@big}[1]{%
  \mathop{\vphantom{\sum}\mathpalette\my@makebig{#1}}\slimits@
}
\newcommand{\my@narrowbig}[1]{%
  \mathop{\vphantom{\sum}\mathpalette\my@narrowmakebig{#1}}\slimits@
}
\AtBeginDocument{%
  \DeclareRobustCommand{\bigplus}{\DOTSB\my@big\my@plus}%
  %\DeclareRobustCommand{\bigtimes}{\DOTSB\my@big\my@times}%
  \DeclareRobustCommand{\bigtimes}{\DOTSB\my@narrowbig\my@narrowtimes}%
  \DeclareRobustCommand{\bigbox}{\DOTSB\my@narrowbig\my@narrowbox}%
}
\newcommand{\my@makebig}[2]{%
  \vcenter{%
    \sbox\z@{$\m@th#1\sum$}%
    \setlength{\unitlength}{0.9\dimexpr\ht\z@+\dp\z@}%
    \hbox{\kern0.1\wd\z@\my@draw{#1}{#2}\kern0.1\wd\z@}%
  }%
}
\newcommand{\my@draw}[2]{%
  \begin{picture}(1,1)
    \linethickness{%
      \ifx#1\displaystyle 1.2\fontdimen8\textfont3\else
      \ifx#1\textstyle 1.1\fontdimen8\textfont3\else
      \ifx#1\scriptstyle1\fontdimen8\scriptfont3\else
      1\fontdimen8\scriptscriptfont3\fi\fi\fi
    }%
    #2
  \end{picture}%
}
\newcommand{\my@plus}{%
  \roundcap
  \Line(0.5,0)(0.5,1)
  \Line(0,0.5)(1,0.5)
}
\newcommand{\my@times}{%
  \roundcap
  \Line(0,0)(1,1)
  \Line(0,1)(1,0)
}
\newcommand{\my@narrowtimes}{%
  \roundcap
  \Line(0,0)(0.75,1)
  \Line(0,1)(0.75,0)
}
\newcommand{\my@narrowbox}{%
  %\roundcap
  \Line(0,0)(0.75,0)
  \Line(0.75,0)(0.75,1)
  \Line(0.75,1)(0,1)
  \Line(0,1)(0,0)
}
\newcommand{\my@narrowmakebig}[2]{%
  \vcenter{%
    \sbox\z@{$\m@th#1\sum$}%
    \setlength{\unitlength}{0.9\dimexpr\ht\z@+\dp\z@}%
    \hbox{\kern0.1\wd\z@\my@narrowdraw{#1}{#2}\kern0.1\wd\z@}%
  }%
}
\newcommand{\my@narrowdraw}[2]{%
  \begin{picture}(0.75,1)
    \linethickness{%
      \ifx#1\displaystyle 1.2\fontdimen8\textfont3\else
      \ifx#1\textstyle 1.1\fontdimen8\textfont3\else
      \ifx#1\scriptstyle1\fontdimen8\scriptfont3\else
      1\fontdimen8\scriptscriptfont3\fi\fi\fi
    }%
    #2
  \end{picture}%
}

%% Attempt #1 to try to reshape \bigtimes...
%% ...leaves too much space after \bigtimes
%\newcommand{\my@times}{%
%  \roundcap
%  \Line(0,0)(0.75,1)
%  \Line(0,1)(0.75,0)
%}

%% Attempt #2 to reshape \bigtimes, using \scalebox instead ...
%% ... makes lines too thin and leaves too much space after \bigtmies
%\newcommand{\my@@times}{%
%  \roundcap
%  \Line(0,0)(1,1)
%  \Line(0,1)(1,0)
%}
%\usepackage{graphicx}
%\newcommand{\my@times}{%
%  \scalebox{0.85}[1]{\my@@times}%
%}

\makeatother

\begin{document}

In-line $
\bigplus_{i\in I} X_i  = \bigtimes_{i\in J} Y_i = \bigbox_{i\in I} X_{i} = \bigcup_{i\in I} Z_{i} =  \bigcap_{n\in I} Z_{i} 
$ here.
\[
\bigplus_{i\in I} X_i = \bigtimes_{i\in J} Y_i = \bigbox_{i\in I} X_{i}= \bigcup_{i\in I} Z_i =  \bigcap_{n\in I} Z_{i} 
\]

In-line $
\bigplus_{i=0}^{\infty} X_i  = \bigtimes_{i=0}^{\infty} Y_i = \bigbox_{i=0}^{\infty} X_{i} = \bigcup_{i=0}^{\infty} Z_{i} =  \bigcap_{n=0}^{\infty} Z_{i} 
$ here.
\[
\bigplus_{i=0}^{\infty} X_i = \bigtimes_{i=0}^{\infty} Y_i = \bigbox_{i=0}^{\infty} X_{i} = \bigcup_{i=0}^{\infty} Z_i =  \bigcap_{n=0}^{\infty} Z_{i} 
\]

\end{document}

答案2

这里的问题只是在 中\my@draw,您使用的picture环境的宽度固定为\unitlength,而不管环境的内容如何picture。因此,符号picture的环境\bigtimes(我猜您预期的宽度为 ,0.85\unitlength因为\scalebox中的\my@times)的宽度仍然为\unitlength

可能有很多方法可以解决这个问题,但我认为最简单的方法是将 中的调用放在中\my@draw,而不是将 的内容放在中。这就是我在以下示例中所做的。\my@makebig\scalebox\my@times\scalebox

\documentclass[fleqn]{article}
\usepackage{amsmath,pict2e}
\usepackage{graphicx}

\usepackage{newtxtext,newtxmath}

\newif\iftimes
\timesfalse
\makeatletter
\newcommand{\my@big}[1]{%
  \mathop{\vphantom{\sum}\mathpalette\my@makebig{#1}}\slimits@%
}
\AtBeginDocument{%
  \DeclareRobustCommand{\bigplus}{\timesfalse\DOTSB\my@big\my@plus}%
  \DeclareRobustCommand{\bigtimes}{\timestrue\DOTSB\my@big\my@times}%
}
\newcommand{\my@makebig}[2]{%
  \iftimes
    \def\scalefactor{0.85}%
  \else
    \def\scalefactor{1}%
  \fi%
  \vcenter{%
    \sbox\z@{$\m@th#1\sum$}%
    \setlength{\unitlength}{0.9\dimexpr\ht\z@+\dp\z@}%
    \hbox{\kern0.1\wd\z@\scalebox{\scalefactor}[1]{\my@draw{#1}{#2}}\kern0.1\wd\z@}%
  }%
}
\newcommand{\my@draw}[2]{%
  \begin{picture}(1,1)
    \linethickness{%
      \ifx#1\displaystyle 1.2\fontdimen8\textfont3\else
      \ifx#1\textstyle 1.1\fontdimen8\textfont3\else
      \ifx#1\scriptstyle1\fontdimen8\scriptfont3\else
      1\fontdimen8\scriptscriptfont3\fi\fi\fi
    }%
    #2
  \end{picture}%
}
\newcommand{\my@plus}{%
  \roundcap
  \Line(0.5,0)(0.5,1)
  \Line(0,0.5)(1,0.5)
}
\newcommand{\my@times}{%
  \roundcap
  \Line(0,0)(1,1)
  \Line(0,1)(1,0)
}
\makeatother

\begin{document}
In-line $
\bigplus_{i\in I} X_i  = \bigtimes_{j\in J} Y_i = \bigcup_{i\in I} Z_{i} =  \bigcap_{n\in I} Z_{i} 
$ here.
\[
\bigplus_{i\in I} X_i = \bigtimes_{j\in J} Y_i = \bigcup_{i\in I} Z_i =  \bigcap_{n\in I} Z_{i} 
\]

In-line $
\bigplus_{i=0}^{\infty} X_i  = \bigtimes_{j=0}^{\infty} Y_i = \bigcup_{i=0}^{\infty} Z_{i} =  \bigcap_{n=0}^{\infty} Z_{i} 
$ here.
\[
\bigplus_{i=0}^{\infty} X_i = \bigtimes_{j=0}^{\infty} Y_i = \bigcup_{i=0}^{\infty} Z_i =  \bigcap_{n=0}^{\infty} Z_{i} 
\]
\end{document}

我认为最好对和\my@makebig都使用相同的命令,但我不想通过向 中添加另一个参数来扰乱in的调用。这就是我添加该语句的原因,但我真的不是专家,我想可能有更好的方法来做到这一点。\bigtimes\bigplus\mathpalette\my@big\my@makebig\iftimes

无论如何,这是我用 pdfLaTeX 编译的示例的输出。

相关内容