-1

I would like to exclude the text between \bgroup and \egroup from appearing in the final PDF, i.e. mark it as a comment during runtime. However, the problem here is that the text is not static and \bgroup and \egroup are in two different command definitions.

How can I realize this specific behaviour?

6
  • 4
    why bgroup and egrouo? but you can put \setbox0\vbox before the \bgroup most likely. Commented Nov 2, 2023 at 23:31
  • 1
    Welcome to TeX.SE.
    – Mico
    Commented Nov 2, 2023 at 23:33
  • I am not from LaTeX community, but I would like to point out that \bgroup and \egroup are part of a lot of macros. You cannot simply re-define it. This is possible only in OpTeX where \_broup and \_egroup are used internally in macros and you can declare \def\bgroup{\setbox0=\_vbox\_broup} if you want to remove texts from \bgroup...\egroup used in your document.
    – wipet
    Commented Nov 3, 2023 at 6:26
  • 1
    Can you please add an example of the code you have?
    – egreg
    Commented Nov 3, 2023 at 9:15
  • @egreg The example where I needed this specific behavior was the following - at that time still unanswered - post: tex.stackexchange.com/questions/699936/….
    – FixFox
    Commented Nov 5, 2023 at 11:24

1 Answer 1

0

Due to a solution found with the help of @David Carlisle, I would like to conclude this post.

It was actually a simple addition of the command. Nothing more. No idea why it works, but it does. Thanks!

Enclosed is the full solution to the problem. The two definitions are triggered at a delimiter start and a delimiter end. Accordingly, everything between the two definitions, i.e. between \bgroup and \egroup, is now blacked out and replaced by 'YOUR_PATH':

\definecolor{mylilas}{RGB}{170,55,241}

\makeatletter

\def\formatPATH{}
\def\formatPATH@start{{\color{mylilas} \textquotesingle C:\textbackslash... }{\bfseries\color{black} YOUR\_PATH}\setbox0\vbox\bgroup}
\def\formatPATH@end{\egroup{\color{mylilas} \textquotesingle}}

\makeatother

A complete solution including the triggering of both definitions can be found in the following original post: Substitute text between delimiters (listings)

5
  • That's not how this site works. As the aim is to build a library of knowledge for future users with the same problem, an answer ought to contain the solution to the problem, not just that you solved your problem. That's not really helpful to know for anybody but you. Commented Nov 5, 2023 at 12:04
  • @samcarter_is_at_topanswers.xyz I hope I was able to constructively implement your criticism of my conclusion and revise my questionable approach during the post finalization. My apologies, I just assumed the answer was already given in full.
    – FixFox
    Commented Nov 5, 2023 at 12:14
  • 1
    Just curious: why not use actual regex (in expl3) to edit the path?
    – Cicada
    Commented Nov 5, 2023 at 13:04
  • 1
    Or even just plain string replace (again, in expl3)?
    – Cicada
    Commented Nov 5, 2023 at 13:07
  • @Cicada Because I am an absolute LaTeX beginner and have no idea - to put it in a nutshell. The solution seemed the best / easiest to me. I'm open to new and even better suggestions. Therefore, also just out of curiosity, the counter question: How would you have implemented it then - yes in expl3, and how?
    – FixFox
    Commented Nov 5, 2023 at 14:21

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