1

So the problem is simple. A function takes something and puts it inside math-mode ($$). Can I influence that from the outside?

Example:

\documentclass{article}
\def\mathmod#1{$#1$}

\begin{document}
  \mathmod{hello world}
\end{document}

prints this: enter image description here Is it possible to cancel that mathmode partly from the outside, to make him print something like this: enter image description here but without moving world out of the function? Maybe there is any command of fixing condition, after which no other command will affect, or something...

2
  • NB! The question is absolutely theoretical, whether it is possible or not. (no practical solution is needed) Commented Mar 26, 2019 at 16:48
  • 1
    Short answer: yes. Long answer: read my answer.
    – user156344
    Commented Mar 26, 2019 at 16:48

1 Answer 1

2

Outside \mathmod you use $ to start and end math mode. Inside it, just to the opposite thing: use $ to start and end text mode (take care of the space!).

\documentclass{article}
\def\mathmod#1{$#1$}
\begin{document}
  \mathmod{hello$ world $and$ hello $world\ again}
\end{document}

enter image description here


PS. You are going to troll most editors with this command ;-) For example, my editor:

enter image description here

1
  • 2
    This reminds me of a sql injection for some reason haha Commented Mar 26, 2019 at 16:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .