473,378 Members | 1,605 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

how to extract LaTeX macro arguments?

I know regex can't do this, so may I ask what the recommended
procedure is for extracting a bracketed TeX argument, which itself can
contain other bracketed TeX arguments?

$string = " text \sometexmacro{arg1}{this is a second {\bf arg}
argument} more text";

and file.pm has a sub that makes it easy to describe all the arguments
to sometexmacro
\sometexmacro
arg1: 'arg1'
arg2: 'this is a second {\bf arg} argument'

if it were even smarter, it could also handle TeX comments and
escapes, such as

file.tex: \sometexmacro{arg1}{this is a second %}
{\bf arg} argument, which handles \} correctly }

Life would be heaven if regex's could do this, because I could then
automatically replace the second argument with what I want it to be.
Alas, they cannot. will they be able to do this in perl6?
Jul 19 '05 #1
4 3399
ivo welch wrote:
I know regex can't do this,
Do you? Please show us the code that made you jump at that incorrect
conclusion. Preferrably a small program that people can run.
so may I ask what the recommended procedure is for extracting a
bracketed TeX argument, which itself can contain other bracketed
TeX arguments?
I'd say that a Perl regular expression would be fine.

<random code fragments snipped>
Life would be heaven if regex's could do this,


Then life _is_ heaven! Isn't that wonderful? :)

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 19 '05 #2
how about an example (if this is possible) then?
Jul 19 '05 #3
ivo welch wrote:
how about an example (if this is possible) then?


Nope. I think people should give it a serious try to solve their
problems themselves before asking for help in this and similar groups,
and you have in no way indicated that you have tried yourself. On the
contrary, considering the way you asked, I'd bet that you are just
trying to have other people do the job for you.

You know, this is not a "we write your code for free" service. It's a
Usenet group for discussing the Perl programming language. Maybe I
should add: This group is defunct, and replaced by comp.lang.perl.misc.

If I was wrong above, and if you want to ask for help there, I do
recommend that you reconsider your posting style.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Jul 19 '05 #4
Thanks for the hint. I had looked at the perlfaq6,

Can I use Perl regular expressions to match balanced text?

Although Perl regular expressions are more powerful than
"mathematical" regular expressions, because they feature conveniences
like backreferences (\1 and its ilk), they still aren't powerful
enough -- with the possible exception of bizarre and experimental
features in the development-track releases of Perl. You still need to
use non-regex techniques to parse balanced text, such as the text
enclosed between matching parentheses or braces, for example.
and I had tried to play with the feature, but I could not figure it
out. I think short one-liner examples fall well within the "please
help" category and not just into the "do the programming for me"
category.

regards, /iaw
Gunnar Hjalmarsson <no*****@gunnar.cc> wrote in message news:<xu********************@newsc.telia.net>...
ivo welch wrote:
how about an example (if this is possible) then?


Nope. I think people should give it a serious try to solve their
problems themselves before asking for help in this and similar groups,
and you have in no way indicated that you have tried yourself. On the
contrary, considering the way you asked, I'd bet that you are just
trying to have other people do the job for you.

You know, this is not a "we write your code for free" service. It's a
Usenet group for discussing the Perl programming language. Maybe I
should add: This group is defunct, and replaced by comp.lang.perl.misc.

If I was wrong above, and if you want to ask for help there, I do
recommend that you reconsider your posting style.

Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Martin Magnusson | last post by:
I'm using a matrix and vector library, that won't compile. When running g++ I get the error message "macro "minor" passed 5 arguments, but takes just 1" The definition of "minor" looks like...
10
by: Karim Thapa | last post by:
Why following macro does not work? #define removebrace(x) x void Foo(int a, int b, char *txt, int d, int e); main() {
14
by: Michael B Allen | last post by:
I just noticed that doing something like the following may fail because it can overwrite u->size before it's evaluated. memcpy(u, buf, u->size); Is it legit that this is a macro as opposed to...
12
by: Laurent Deniau | last post by:
I was playing a bit with the preprocessor of gcc (4.1.1). The following macros expand to: #define A(...) __VA_ARGS__ #define B(x,...) __VA_ARGS__ A() -nothing, *no warning* A(x) -x ...
4
by: Max TenEyck Woodbury | last post by:
I need a macro that will take an arbitrarily long list of arguments where each argument needs to be passed to another macro. Is it possible to write such a macro? If so, could you please...
9
by: Francois Grieu | last post by:
Consider this macro // check if x, assumed of type unsigned char, is in range #define ISVALID(x) ((x)>=0x20 && (x)<=0x7E) Of course, this can't be safely used as in if (ISVALID(*p++)) foo();...
6
by: jason | last post by:
Hi, I learned my lesson about passing pointers, but now I have a question about macros. Why does the function work and the MACRO which is doing the same thing on the surface, does not work in...
5
by: Francois Grieu | last post by:
One of the C compiler that I use <OT>(Keil's CX51)</OTbarks at #define a(b) b int main(void){return a( #if 0 #endif 0);} More generally, this compiler seems confused by any preprocessing...
5
by: Peng Yu | last post by:
Hi, I want a macro #expand that can be expanded to one of the following depending on its argument f(i1) f(i1, i2) f(i1, i2, i3) ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.