[Tex/LaTex] How to format K notation for continued fractions

charactersmath-modemath-operators

Over here is a recent paper on continued fractions, and I was wondering how I could format Gauss' K notation in this fashion. Here is a picture to demonstrate what I mean:

K notation image

I am unsure how to format the alligned position of the + signs and ellipsis without aligning them with the vinculums of the fractions a(k)/b(k).

To format the size, font, indices, etc of the K notation, I tried doing: \operatornamewithlimits{\Large{\Bigg\mathcal{K}}}}_{m=1}^\infty
or
\operatorname*{\Large{\Bigg\mathcal{K}}}}\limits_{m=1}^\infty
and experimented with \large, \big, \bigg, with or without.

It seems that the size is right, but the indices are… way off. Can somebody help me, please? I have searched for some related posts (e.g. here), but amidst my search, I could not find the appropriate format I am looking for, as depicted above.

My thoughts: I think I need to install a package (e.g. amsmath) that can enhance typesetting and other facilities. I am writing a paper on Overleaf – does Overleaf come wit this package?

I am not new to TeX, but I believe this is either my first or second post. If I am doing something wrong, or failing to follow the guidelines, please let me know asap, and I will try to amend my question/post accordingly.

Thank you in advance.

Best Answer

You can download the source of the arXiv paper at https://arxiv.org/format/1909.13597 (choose Download source to download the .tex file).

The paper uses

\def\contFracOpe{%
    \operatornamewithlimits{%
        \mathchoice{% * Display style
            \vcenter{\hbox{\huge $\mathcal{K}$}}%
        }{%           * Text style
            \vcenter{\hbox{\Large $\mathcal{K}$}}%
        }{%           * Script style
            \mathrm{\mathcal{K}}%
        }{%           * Script script style
            \mathrm{\mathcal{K}}%
        }
    }
}

That definition seems to come from projetmbc's answer to How to typeset a continued fraction in the following format? which in term refers to user2478's answer to How to create my own math operator with limits?.

I usually prefer \newcommand over \def for commands in the preamble and the \mathrm's are unnecessary, so I would probably make that definition read

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}

\newcommand\ContFracOp{%
  \operatornamewithlimits{%
    \mathchoice
     {\vcenter{\hbox{\huge $\mathcal{K}$}}}
     {\vcenter{\hbox{\Large $\mathcal{K}$}}}
     {\mathcal{K}}
     {\mathcal{K}}}}


\begin{document}
$\ContFracOp\dots\ContFracOp_{k=1}^m x_k e^{\ContFracOp_{k=1}^m x_k}$

\[\ContFracOp\dots\ContFracOp_{k=1}^m x_k e^{\ContFracOp_{k=1}^m x_k}\]
\end{document}

\ContFracOp with \mathchoice

An alternative would be to base \ContFracOp on egreg's answer that makes use of graphicx's \resizebox to scale the symbol to the same size as \sum.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}

\makeatletter
\DeclareRobustCommand\bigop[2][1]{%
  \mathop{\vphantom{\sum}\mathpalette\bigop@{{#1}{#2}}}\slimits@
}
\newcommand{\bigop@}[2]{\bigop@@#1#2}
\newcommand{\bigop@@}[3]{%
  \vcenter{%
    \sbox\z@{$#1\sum$}%
    \hbox{\resizebox{\ifx#1\displaystyle#2\fi\dimexpr\ht\z@+\dp\z@}{!}{$\m@th#3$}}%
  }%
}
\makeatother

\newcommand{\ContFracOp}{\DOTSB\bigop[.96]{\mathcal{K}}}

\begin{document}
$\ContFracOp\dots\ContFracOp_{k=1}^m x_k e^{\ContFracOp_{k=1}^m x_k}$

\[\ContFracOp\dots\ContFracOp_{k=1}^m x_k e^{\ContFracOp_{k=1}^m x_k}\]
\end{document}

\ContFracOp with scalebox

I found the magic number .96 in the optional argument to \bigop in the definition of \ContFracOp by trial and error. It helps manually correct the scaling of the symbol to match the height of \sum as closely as possible.

Related Question