9

I am unsatisfied with the way subscript is rendered for the Greek letter \chi. This particular letter is rendered with a small downward offset. I occasionally have to prefix the subscript with \sciptscriptstyle such that, in effect, an expression may look like

\sup{\chi_{\scriptscriptstyle A_n}(x)}[n]

where

\RenewDocumentCommand{\sup}{m O{}}{
    \operatorname{sup}\ifstrempty{#2}{}{\limits_{\mathclap{\substack{\expandafter{\scriptscriptstyle{#2}}}}}}
        \expandafter{#1} 
}

(I admit this snippet is a little messy, especially due to the uncanonical declaration of the optional argument as O{} and testing via \ifstrempty instead of o for the argument type and IfNoValueTF--using the xparse package. I am not entirely clear yet about what syntax is more straightforward.)

Is there a way to redefine \chi keeping the syntax in line with all semantically equivalent concepts, i.e., letters, but having only \chi's subscript expressions smaller or slightly lower? To clarify, I am thinking of redefining the subscript operator _ for \chi only. But I naively suppose TeX' grammar would not let me do that.

An evident work-around would involve defining a new macro using a different syntax like

\newcommand{\Chi}[1]{\chi_{\scriptscriptstyle{#1}}}

So effectively, what I want is just

\chi_{expr}

where expr is rendered smaller or offset lower than default.

  • Alternately, you could render \chi a slight distance vertically higher (all the time, not just with subscripts). While messing with a designer's fonts is not ideal, the alternative you propose of setting different size subscripts at the same nesting level could be very confusing. – Steven B. Segletes Jul 15 '14 at 11:06
  • What about $\chi_{\textscit A_n}? The problem is not so much with the letter chi than with capital letters in subscripts. Or you might define a new math alphabet with italic smallcaps, and use mathchoice to use this new alphabet in (sub)subscripts. – Bernard Jul 15 '14 at 11:13
  • @StevenB.Segletes: I would rather abstain from changing the familiar look of \chi, changing it may seem confusing to some readers. – user59118 Jul 15 '14 at 11:17
  • @Bernard: There are subscript expressions I come across in particular disciplines quite often that are less trivial, e.g., \chi_{\bigcup_{j \in \mathbb{N}} A_j}. – user59118 Jul 15 '14 at 11:20
  • I see. I'm afraid there's no universal solution. Maybe redeclaring the font sizes for (sub)subscripts… But then, maybe you'll find "ordinary" subscripts too small. – Bernard Jul 15 '14 at 11:24
4

Using \scriptscriptstyle is not a good typographical device, because it will make unbalanced symbols.

Here's the way for ensuring the subscript is shifted down as if there was a superscript.

\documentclass{article}
\usepackage{amsmath,xparse}

\let\latexchi\chi
\makeatletter
\renewcommand\chi{\@ifnextchar_\sub@chi\latexchi}
\newcommand{\sub@chi}[2]{% #1 is _, #2 is the subscript
  \@ifnextchar^{\subsup@chi{#2}}{\latexchi^{}_{#2}}%
}
\newcommand{\subsup@chi}[3]{% #1 is the subscript, #2 is ^, #3 is the superscript
  \latexchi_{#1}^{#3}%
}
\makeatother

\begin{document}
\noindent
$\latexchi_{A}\chi_{A}$\\[2ex]
$\latexchi_{A_{n}}\chi_{A_{n}}$\\[2ex]
$\chi_{A}\quad\chi_{A}^{2}\quad\chi^{2}_{A}\quad\chi^{2}\quad\chi$
\end{document}

enter image description here

3

Yet another possibility one might want to consider: Redefine \chi so that the bottom half of a "math strut" is inserted automatically after the character. (Aside: A mathstrut is a TeX object of zero width -- hence it's invisible -- and the height and depth of a round parenthesis, i.e., ).) That way, the position of any subscripts will be keyed off the {\chi\mathstrut} combo rather than the \chi symbol. Because the depth of the mathstrut exceeds the depth of \chi, the subscript will end up being placed lower -- as desired.

The solution below employs the amsart document class, which loads the amsmath package automatically. For non-AMS document classes, be sure to load the amsmath package so that the \smash[t]{...} macro is available.

\documentclass[a4paper]{amsart}

\makeatletter
\@ifdefinable\@latex@chi{\let\@latex@chi\chi}
\renewcommand*\chi{{\@latex@chi\smash[t]{\mathstrut}}} % want only bottom half of \mathstrut
\makeatletter

\begin{document}
Text before $\chi_{A}$, text after.

Text before $\chi_{S_{i}}$, text after

Another couple of lines of text for testing consistency of the gap between the 
baselines.  Some more text.  Some more text.
\end{document}

Output:

Output of the code

  • @Mico: Good suggestion. Why don't you directly edit my answer? – GuM Jun 16 '15 at 13:52
  • I've taken you up on your suggestion. :-) – Mico Jun 16 '15 at 14:07
  • @Mico: Now I am facing the problem: how can I pass on to you the upvote I received? Your edit made a substantial improvement to my answer, and I feel like I’m stealing reputation from you! :-) – GuM Jun 16 '15 at 16:23
  • Nah, no stealing involved here! – Mico Jun 16 '15 at 22:19
2
\documentclass{article}
\usepackage{mathtools}

\newcommand{\mychi}{\raisebox{0pt}[1ex][1ex]{$\chi$}}
\newlength{\temp}

\begin{document}
\[ \textrm{before}\quad \chi_A^2 \quad\textrm{after}\quad \mychi_A^2 \]

\settoheight{\temp}{$\chi$}
\noindent\the\temp\newline
\settoheight{\temp}{\mychi}
\the\temp
\end{document}

chi squared

You can fine tune the \rasisebox parameters as desired.

1

I just came across the same problem. The solution that works for me is just writing it as a sub-subscript:

\chi_{_{A_n}}

Rendered code

0

You could use the power of xparse to define new sub- and superscript arguments and pass them as optional arguments. Here is the full code and explanation.

Basically you use a and b arguments in xparse that search for _{#1} and ^{#2} respectively and then do whatever you want with those arguments. I use here the solution from egreg to show you how easy it is.

\let\originalchi\chi
\RenewDocumentCommand\chi{ab}
  {\originalchi
   \IfValueT{#1}{_{#1}}%
   \IfValueTF{#2}{^{#2}}{^{}}}
...
$\originalchi_{A}\chi_{A}$\\[2ex]
$\originalchi_{A_{n}}\chi_{A_{n}}$\\[2ex]
$\chi_{A}\quad\chi_{A}^{2}\quad\chi^{2}_{A}\quad\chi^{2}\quad\chi$

a and b (and A{<default>} and B{<default>}) behave exactly like the rest of xparse arguments.

Here's the full compilable code:

\documentclass{scrartcl}
\usepackage{mathtools,xparse}

\ExplSyntaxOn
\cs_new_protected:Npn \__xparse_count_type_k:w #1
 {
  \__xparse_single_token_check:n { #1 }
  \quark_if_recursion_tail_stop_do:Nn #1 { \__xparse_bad_arg_spec:wn }
  \__xparse_count_mandatory:N
 }
\cs_new_protected:Npn \__xparse_count_type_K:w #1 #2
 {
  \__xparse_single_token_check:n { #1 }
  \quark_if_recursion_tail_stop_do:nn { #2 } { \__xparse_bad_arg_spec:wn }
  \__xparse_count_mandatory:N
 }
\cs_new_protected:Npn \__xparse_add_type_k:w #1
 { \exp_args:NNo \__xparse_add_type_K:w #1 { \c__xparse_no_value_tl } }
\cs_new_protected:Npn \__xparse_add_type_K:w #1 #2
 {
  \__xparse_flush_m_args:
  \__xparse_add_grabber_optional:N K
  \tl_put_right:Nn \l__xparse_signature_tl { #1 { #2 } }
  \__xparse_prepare_signature:N
 }
\cs_new_protected:Npn \__xparse_add_expandable_type_k:w #1
 {
  \exp_args:NNo \__xparse_add_expandable_type_K:w #1 { \c__xparse_no_value_tl }
 }
\cs_new_protected_nopar:Npn \__xparse_add_expandable_type_K:w #1 #2
 {
  \__msg_kernel_error:nnx { xparse } { invalid-expandable-argument-type } { K }
  \__xparse_add_expandable_type_m:w % May be create this?
 }
\cs_new_protected:Npn \__xparse_grab_K:w #1 #2 #3 \l__xparse_args_tl
 {
  \__xparse_grab_K_aux:NnnNn #1 { #2 } { #3 } \cs_set_protected_nopar:Npn
   { _ignore_spaces }
 }
\cs_new_protected:Npn \__xparse_grab_K_long:w #1 #2 #3 \l__xparse_args_tl
 {
  \__xparse_grab_K_aux:NnnNn #1 { #2 } { #3 } \cs_set_protected:Npn
   { _ignore_spaces }
 }
\cs_new_protected:Npn \__xparse_grab_K_trailing:w #1 #2 #3 \l__xparse_args_tl
 {
  \__xparse_grab_K_aux:NnnNn #1 { #2 } { #3 } \cs_set_protected_nopar:Npn
   { _ignore_spaces }
 }
\cs_new_protected:Npn \__xparse_grab_K_long_trailing:w #1 #2 #3 \l__xparse_args_tl
 {
  \__xparse_grab_K_aux:NnnNn #1 { #2 } { #3 } \cs_set_protected:Npn
   { _ignore_spaces }
 }
\cs_new_protected:Npn \__xparse_grab_K_aux:NnnNn #1 #2 #3 #4 #5
 {
  \exp_after:wN #4 \l__xparse_fn_tl ##1
   {
    \__xparse_add_arg:n { ##1 }
    #3 \l__xparse_args_tl
   }    
  \use:c { peek_meaning_remove #5 :NTF } #1
   { \l__xparse_fn_tl }
   {
    \__xparse_add_arg:n { #2 }
    #3 \l__xparse_args_tl
   }
 }

\prop_put:Nnn \c__xparse_shorthands_prop { a } { k \sb }
\prop_put:Nnn \c__xparse_shorthands_prop { b } { k \sp }
\prop_put:Nnn \c__xparse_shorthands_prop { A } { K \sb }
\prop_put:Nnn \c__xparse_shorthands_prop { B } { K \sp }
\ExplSyntaxOff

\let\originalchi\chi
\RenewDocumentCommand\chi{ab}
  {\originalchi
   \IfValueT{#1}{_{#1}}%
   \IfValueTF{#2}{^{#2}}{^{}}}

\begin{document}
\noindent
$\originalchi_{A}\chi_{A}$\\[2ex]
$\originalchi_{A_{n}}\chi_{A_{n}}$\\[2ex]
$\chi_{A}\quad\chi_{A}^{2}\quad\chi^{2}_{A}\quad\chi^{2}\quad\chi$
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.