2

The following code, slightly modified from https://tex.stackexchange.com/a/552769/13492, allows creating new symbols \bigplus, \bigtimes, and \bigbox.

However, it hard-codes the scaling factor \scalefactor used to determine the horizontal shinkage of the symbols as produced, in the first instance, by applying in order \my@makebig and then \my@big to the pictures created by applying \my@draw to the basic forms \my@plus, \my@times, and \my@box.

The hard-coded \scalefactor is controlled by \ifnarrow.

Question:

How can the code be modified so as to use a new, additional, argument to specify the scaling factor directly and separately for each individual symbol (and such other similar symbols as I may choose to create).

Ideally, that new argument would be optional, defaulting to 1.

I just don't see which of the commands to modify how so as to accomplish this.

Clarification:

The commands \myplus, \mytimes, and \mybox are to be left with each having no arguments. Rather, a new argument — should be added to \my@big, \mymakebig, and/or \my@draw (whichever are needed for the purpose). The new, optional, argument is then used once, in the preamble, separately for each of the \big... commands. In other words, to allow something like this in the preamble:

\DeclareRobustCommand{\bigtimes}{\DOTSB\my@big[0.8]\my@times}    
\DeclareRobustCommand{\bigplus}{\DOTSB\my@big\my@plus}

And then in the body of the document I still use, e.g.:

$\bigplus_{i\in I} X_i  = \bigtimes_{i\in J} Y_i$ 

The code now:

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

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

\newif\ifnarrow \narrowfalse \makeatletter \newcommand{\my@big}[1]{% \mathop{\vphantom{\sum}\mathpalette\my@makebig{#1}}\slimits@% } \AtBeginDocument{% \DeclareRobustCommand{\bigplus}{\narrowfalse\DOTSB\my@big\my@plus}% \DeclareRobustCommand{\bigtimes}{\narrowtrue\DOTSB\my@big\my@times}% \DeclareRobustCommand{\bigbox}{\narrowfalse\DOTSB\my@big\my@box}% } \newcommand{\my@makebig}[2]{% \ifnarrow \def\scalefactor{0.8}% \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.15\fontdimen8\textfont3\else \ifx#1\textstyle 1.05\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@box}{% \roundcap \Line(0,0)(1,0) \Line(1,0)(1,1) \Line(1,1)(0,1) \Line(0,1)(0,0) } \makeatother

\begin{document}

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

In-line $ \bigplus_{i=0}^{\infty} X_i = \bigtimes_{i=0}^{\infty} Y_i = \bigbox_{i=0}^{\infty} X_{i} = \bigcap_{i=0}^{\infty} Z_{i} = \bigcup_{n=0}^{\infty} Z_{i} = \sum_{i =0}^{\infty} H_{i} $. Display: [ \bigplus_{i=0}^{\infty} X_i = \bigtimes_{i=0}^{\infty} Y_i = \bigbox_{i=0}^{\infty} X_{i} = \bigcap_{i=0}^{\infty} Z_i = \bigcup_{n=0}^{\infty} Z_{i} = \sum_{i=0}^{\infty} H_{i} ] \end{document}

Output: This is what xelatex produces; the output from pdflatex is similar.

big ops symbols

Related: The issue arises from my original question Make big plus and big times symbols and the answer https://tex.stackexchange.com/a/552557/13492 to it.

murray
  • 7,944

1 Answers1

4

REVISED, based on comment.

\documentclass[fleqn]{article}
\usepackage{amsmath,pict2e,graphicx}
\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}[2][1]{% \mathop{\vphantom{\sum}\def\scalefactor{#1}\mathpalette\my@makebig{#2}}\slimits@% } \AtBeginDocument{% \DeclareRobustCommand{\bigplus}{\DOTSB\my@big[.5]\my@plus}% \DeclareRobustCommand{\bigtimes}{\DOTSB\my@big[.75]\my@times}% \DeclareRobustCommand{\bigbox}{\DOTSB\my@big\my@box}% } \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@\scalebox{\scalefactor}[1]{\my@draw{#1}{#2}}\kern0.1\wd\z@}% }% } \newcommand{\my@draw}[2]{% \begin{picture}(1,1) \linethickness{% \ifx#1\displaystyle 1.15\fontdimen8\textfont3\else \ifx#1\textstyle 1.05\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@box}{% \roundcap \Line(0,0)(1,0) \Line(1,0)(1,1) \Line(1,1)(0,1) \Line(0,1)(0,0) } \makeatother

\begin{document}

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

In-line $ \bigplus_{i=0}^{\infty} X_i = \bigtimes_{i=0}^{\infty} Y_i = \bigbox_{i=0}^{\infty} X_{i} = \bigcap_{i=0}^{\infty} Z_{i} = \bigcup_{n=0}^{\infty} Z_{i} = \sum_{i =0}^{\infty} H_{i} $. Display: [ \bigplus_{i=0}^{\infty} X_i = \bigtimes_{i=0}^{\infty} Y_i = \bigbox_{i=0}^{\infty} X_{i} = \bigcap_{i=0}^{\infty} Z_i = \bigcup_{n=0}^{\infty} Z_{i} = \sum_{i=0}^{\infty} H_{i} ] \end{document}

enter image description here

  • That's not the way I want to use the new argument: I want to use the argument once, in each of the definitions of \bigplus,\bigtimes,\bigboxand *not* in the body of the document. So those three commands should *not* themselves have any arguments whatsoever. Thus I want to be able to do in the preamble something like\DeclareRobustCommand{\bigtimes}{\DOTSB\my@big[0.8]\my@times}and\DeclareRobustCommand{\bigplus}{\DOTSB\my@big\my@plus}. Thus scaling factors are fixed (separately) in preamble for each\big...command, and the\big...` commands are used without arguments. – murray Jul 09 '20 at 14:59
  • @murray Done, per your request. – Steven B. Segletes Jul 09 '20 at 15:07
  • Preamble code exactly what I want, thank you! (But I would not be using the optional [.5] in the body of the document, since that produces spurious output [.5] after the symbols! after the big symbols in the first "In-line" and "Display" output!) – murray Jul 09 '20 at 15:21
  • @murray Of course. Silly me. Fixed. – Steven B. Segletes Jul 09 '20 at 15:28