last day (15 days later) » 

16:50
0
A: xparse modal command – custom macro like \bfseries

muzimuzhi ZA first try: \autoScoped{<arg>} opens a scope which can be auto ended by \\ or \par, and then uses <arg>. Note this is not the usual way that LaTeX should be used and this first try is far from complete and might break many things. \documentclass{article} \usepackage{xpatch} \makeatletter \newi...

I think the third example should be with a double Enter new line. Wow, it works great. However, if I replace \bfseries and \mdseries with [ and ] respectively a space before ] appers. Also it doesn't work in amsmath environments, unfortunately :( imgur.com/4vF2dgB
@antshar 1) No, my answer cannot handle double Enter new line. 2) Generally, \autoScoped and \end@scope@if@in can only contain declarative commands, which means it should not produce any output. 3) Yes, and there are many many more cases (in center env, in tabular env, ...) it doesn't work. As I pointed in my answer, you almost should not use latex in this way.
1) What do you mean? It works great for me with double Enter new line. 3) Why doesn't it work in those environments?
@antshar 1) TeX automatically converts consecutive new line characters to \par, so the patch to \par works. 2) Because in those environments, the definition of \` or \par` (or both of them) is changed.
Is it possible to redefine \\ glabaly. Or how can I redefine \\ in them?
16:50
@antshar Support for list and amsmath envs is added.
Great! Almost perfect. Just to note, the original question is about adding characters from both sides. \bfseries was just for an example. But that is not the problem, because I can easily replace the condition with desired character. The problem that currently is – if you try to add this on the last line of the multline environment, bracket appears at the different spot: imgur.com/VV4dY3B         And also if I try to use several of commands on one line a b \autoScoped c d \autoScoped e f one bracket is missing: imgur.com/whiFagV
I'm not sure I have the interest to continue this patch.
1) As you have noticed, if you want to use this auto-delimited-scoping to actually adding characters, you must be careful about the space character.
It is really sad :(
I think you've almost done it. I am in great need of this.
2) What's the corresponding input of imgur.com/VV4dY3B (problematic multline output)?
Here is the code I am using for that:
```
\begin{multline*}
abc \autoScoped\\
\autoScoped def\\
ghi \autoScoped jkl mno
\end{multline*}
```
16:55
3) The missing bracket is caused by "nesting is not supported", which I have mentioned in my answer.
@antshar In this mulline* env, the second \autoScoped is not normally ended. I need to read more source code of amsmath pacakge, before telling you why it's wrong and how to automatically end a scope at the end of amsmath env.
Ok. I will be really grateful if you manage to fix issues. Looking forward to hearing from you!
I understand what you require would be useful in some cases, and that requirement is understandable from a programming perspective. But restricted by how LaTeX2e and its packages are designed and implemented, adding another kind of usage may really require many tough works.
I will have a try, but I cannot make a promise right now.
Can I know when you want to use this auto-delimited utility? Maybe it is already supported by LaTeX editors.
17:20
At first I was looking for the answer to this question: https://tex.stackexchange.com/q/546196
I got no any answer that would work as I would like to. Nevertheless, the only answer made me think of a workaround: if the command would put `\hspace{3em}` when the `\myspace` is placed and `\hspace{-3em}` at the end of the current line it would give me the desired result.
So I asked a question how I can fence text with something.

But now, I see even more application of `\autoScoped`. I hope you will be able to make it work perfecly.
17:39
I really doubt whether we are at the almost-done stage. Usually there would be more uncovered edge cases. Then gradually the implementation will need more and more patching lines. For a technical attempt, I will have a try; for practical usages, I recommend to not use LaTeX in this way.
 
6 hours later…
23:32
After a rather amount of trying, it turns out that currently I am not capable of patching amsmath pacakge. Sorry. To become capable of, I might need to read and understand the source code of amsmath pacakge (file amsmath.sty) thoroughly. And that should take days or even weeks.

last day (15 days later) »