0

see overlay symbols

I'd like to create a symbol that I can use like any other ordinary symbol, except that it takes other symbols as part of its visual and that might include itself, limited by some depth.

\s{a}{b}

might be something like

\newcommand{\s}[2]{x^#1_#2}
\s{\s}{\s}

would then be something like

$x^{x^{x^{x^{x}_x}_x}_x}_x{...}$

I'd like to be able to using common sense positioning and such that all works out and some way to limit the recursion.

In fact, I wouldn't mind a series of commands that generate at each level so I can mix and match.

It is essentially creating and IFS.

I've tried to use the linked method, which is nice for it's easy of use in positioning, scaling, rotation, but they seem to be absolutely set(rather than relative to the recursion) and the the symbol won't take itself.

It should work with math mode too, which was part of the problem of trying to get it all to work out using the linked method.

closed as unclear what you're asking by David Carlisle, Bobyandbob, user36296, Stefan Pinnow, Phelype Oleinik Sep 11 '18 at 10:55

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Are you aware of this answer? – user121799 Sep 6 '18 at 13:04
  • 1
    @marmot This is not exactly what I want. It is only for upper, I need recursion... Meaning, IFS. Look up what an IFS and then you'll understand. Basically a "special symbol" that zones around it in which are played new symbols which also have zones and can hold symbols(which might be more of these special symbols). The thing is, the zones are rotated and scaled recursively in relation to their depth and location. – AbstractDissonance Sep 6 '18 at 13:44
  • 2
    the problem statement isn't that clear, as the problem with the example definition is not that "it can not take itself as argument" it can, the problem is that the arguments are not supplied for the inner calls, so {\s} is already an error. perhaps you want a syntax like \s{*}{*} where * means to re-insert \s{*}{*} up to some fixed number of times? – David Carlisle Sep 6 '18 at 15:20
  • 2
  • 2
    your title is "recursive symbols" and your example code fragment is (modulo syntax errors) a non terminating infinitely recursing call of \s but in comments you complain about any answer focussing on recursion. I voted to close the question as "unclear" – David Carlisle Sep 11 '18 at 6:56
6

I would guess you want something like this

enter image description here

for a level 3 expansion, the \typeout below shows

x^{x^{x^{x^{}_{} }_{x^{}_{} } }_{x^{x^{}_{} }_{x^{}_{} } } }_{x^{x^{x^{}_{} }_{x^{}_{} } }_{x^{x^{}_{} }_{x^{}_{} } } } 

from an input

\documentclass{article}

\def\s#1#2{x^{#1}_{#2}}


\def\foo#1#2{%
\ifnum#1>0
#2{\foo{\numexpr#1-1\relax}#2}{\foo{\numexpr#1-1\relax}#2}
\else
#2{}{}
\fi}

\begin{document}


\typeout{\foo{3}{\s}}
$\foo{3}{\s}$

\end{document}
  • Ok, but the example was just an example, I need to be able to use positioning and rotation and be able to substitute other symbols. You guys are fixating way to much on the example when it was just to try to give you an idea. Again, Look up IFS and think of each region as a symbol(it is not exactly the same but it is close enough). For example, I was using ^ and _ as a simple quick example but look at the overlay link and you will see how general I want. I want to basically take symbol generation but allow for "nesting"/"recursion". – AbstractDissonance Sep 6 '18 at 16:10
  • What I'd expect is that for each place holder I can specify the symbol that goes there but any geometric transformations on the symbols will recursively nest appropriate(this means that a rotation of anything nested will rotate). It's a pretty easy concept to understand if you understand IFS but hard to explain in detail. I will give an example though. – AbstractDissonance Sep 6 '18 at 16:12
  • 4
    @AbstractDissonance your comments here do not match your question at all as far as I can tell, and your question contains no example that shows a problem other than an example that exhibits infinite recursion (\s calling \s). So I suggest you accept this answer and ask a new question that you meant to ask, along with an example that can be run that fails. Otherwise I have no idea how I could edit this answer. – David Carlisle Sep 10 '18 at 13:12
  • 6
    The site is for asking and answering questions not setting coding challenges unrelated to the question, sorry. – David Carlisle Sep 10 '18 at 13:44

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