I would not recommend my answer, which is quite verbose, not very handy, and probably not bullet proof, but it is interesting enough to share hopefully.
The idea is to create the annotations outside the \left (
\right )
brackets, then to move them horizontally using the \hphantom
macro. The \mathclap
macro forces the annotations to overlap the annotated content.
You can use \hphantom{\hspace{...px}}
for positionning, but using the annotated content is more accurate. However, using the annotated content can be tricky, and it's not easy to understand how to work with it. For example, try to understand why I have to use \vphantom
here:
% search for this comment in the code below
\left ( \vphantom{ \delta } k \right )
You will probably think of it for a couple of minutes. I'm sorry but I'm afraid my english is not good enough to try an explanation...
Here is a demo (tested with Stackedit v5.14.10). The only required macros are \freeunderset
, freeoverbrace
, the remaining is for fun or readability. Enjoy!
% required macros
\def\freeundersetstar#1#2#3{
\mathclap{ \underset{ #2 }{ #1 } \hphantom{ #3 } }
}
\def\freeundersetnostar#1#2#3{
\mathclap{ \underset{ #2 }{ \phantom{ #1 } } \hphantom{ #3 } }
}
\def\freeunderset#1#2#3{
\@ifstar
{ \freeundersetstar{#1}{#2}{#3} } % debug macro
{ \freeundersetnostar{#1}{#2}{#3} } % actual macro
}
\def\freeoverbracestar#1#2#3{
\mathclap{ \overbrace{ #1 }^{ \substack{ #2 } } \hphantom{ #3 } }
}
\def\freeoverbracenostar#1#2#3{
\mathclap{ \overbrace{ \phantom{ #1 } }^{ \substack{ #2 } } \hphantom{ #3 } }
}
\def\freeoverbrace#1#2#3{
\@ifstar
{ \freeoverbracestar{#1}{#2}{#3} } % debug macro
{ \freeoverbracenostar{#1}{#2}{#3} } % actual macro
}
% extra macros for fun
\def\0#1{}
\def\1#1{#1}
\def\2#1{#1\1{#1}}
\def\3#1{#1\2{#1}}
\def\+#1#2#3{#1{#3}#2{#3}}
\def\*#1#2#3{#1{#2{#3}}}
\def\hereup#1#2{ \substack{ \uparrow #1{ \\[-.5px]| } \\[2px] #2 } }
\def\heredown#1#2{ \substack{ #2 \\[1px] #1{ |\\[-.5px] } \downarrow } }
% extra macros for readability
\def\d{
\mathrm d
}
\def\delta{
\frac{ b - a }{ n }
}
\def\intdef{
\int_a^b f( x ) \d x
= \lim_{ n \to +\infty }
\delta \sum_{ k = 0 }^{ n - 1 }
f \left ( a + \delta k \right )
}
% experiment
\text{ experiment } \\
\boxed{
\intdef
\! % extra space fix
\red{
\freeunderset { k }
{ \hereup{ \1 }{ \text{ a tiny } \\ \text{ step } } }
% search for this comment in the code below
{ \left ( \vphantom{ \delta } k \right ) }
%* % uncomment to reveal #1
}
\red{
\freeoverbrace { \delta }
{ \text{ a tiny distance } \\ \text{ called $\scriptsize \d x$ } }
{ \left ( k \delta k \right ) }
%* % uncomment to reveal #1
}
}
% control
\\[.25em]
\boxed{ \intdef } \\
\text{ control }