Re: LaTeX question w.r.t \input@path

2011-04-05 Thread Jean-Marc Lasgouttes

Le 04/04/11 21:47, Hellmut Weber a écrit :

Hi list,
recently in another post I found the internal LaTeX macro

   \input@path

mentioned. Putting this (surrounded by \makeatletter and \makeatother)
in an ERT eventually gives me the correct path to my LyX document as
string in the document.


Note that this \input@path is not defined when you export to LaTeX, only 
when running inside LyX. So your code should be robust to that situation...


JMarc


Re: LaTeX question w.r.t \input@path

2011-04-05 Thread Hellmut Weber
Am 04.04.2011 23:32, schrieb Julien Rioux:
 On 04/04/2011 3:47 PM, Hellmut Weber wrote:
 Hi list,
 recently in another post I found the internal LaTeX macro

\input@path

 mentioned. Putting this (surrounded by \makeatletter and \makeatother)
 in an ERT eventually gives me the correct path to my LyX document as
 string in the document.

 S many thanks to the poster of that other message (soem days
 ago) !

 Here is now my question to the LaTeX gurus:
 How can I define a LaTeX macro which gives me the END of the string
 delivered by \input@path?
 To give a concrete example: When I open document test-01.lyx with LyX in
 the directory

 /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

 and compile my document it shows the correct path

 /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/

 Fine.

 What I would like to derive from this string is
 /.../Lyx-Tests/Inputpath/blam/ ;-)
 See what I mean?

 My LaTeX experience told me the need for \makeat...,
 but this transformation I'm not able to do in LaTeX.


 Any help appreciated


 Cheers

 Hellmut


 
 kludge solution, if you know how deep your paths are:
 
 \def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
 \def\removeprefix#1{\expandafter\removeprefixx#1}
 
 \removeprefix{\input@path}
 
Hi Julien,
thanks for your answer ;-)

I think I got the basic idea

BUT i Do NOT know the length the path delivered by \input@path.
To make clear what I'm looking for I put it in python code:

leo@sylhepta ~ $ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type help, copyright, credits or license for more information.
 def shorten_path(path, len):
...   return '/.../' + '/'.join(path.split('/')[-len:])
...
 shorten_path('/home/leo/leo/Test/abc',2)
'/.../Test/abc'


Can this be done in (La)TeX?


Thanks again and thanks to all others who contributed

Best regards

Hellmut

-- 
Dr. Hellmut Weber m...@hellmutweber.de
Degenfeldstraße 2 tel   +49-89-3081172
D-80803 München-Schwabing mobil +49-172-8450321
please: No DOCs, no PPTs. why: tinyurl.com/cbgq


Re: LaTeX question w.r.t \input@path

2011-04-05 Thread Richard Heck

On 04/05/2011 03:20 AM, Hellmut Weber wrote:


To make clear what I'm looking for I put it in python code:

leo@sylhepta ~ $ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type help, copyright, credits or license for more information.

def shorten_path(path, len):

...   return '/.../' + '/'.join(path.split('/')[-len:])
...

shorten_path('/home/leo/leo/Test/abc',2)

'/.../Test/abc'
Can this be done in (La)TeX?


Yes, but it involves magic. This post

http://stackoverflow.com/questions/2402354/split-comma-separated-parameters-in-latex

describes how to split on commas and this one on spaces
http://tex.stackexchange.com/questions/12810/how-do-i-split-a-string
They can both be adapted.

Richard



Re: LaTeX question w.r.t \input@path

2011-04-05 Thread Hellmut Weber
Am 04.04.2011 23:32, schrieb Julien Rioux:
 On 04/04/2011 3:47 PM, Hellmut Weber wrote:
 Hi list,
 recently in another post I found the internal LaTeX macro

\input@path

 mentioned. Putting this (surrounded by \makeatletter and \makeatother)
 in an ERT eventually gives me the correct path to my LyX document as
 string in the document.

 S many thanks to the poster of that other message (soem days
 ago) !

 Here is now my question to the LaTeX gurus:
 How can I define a LaTeX macro which gives me the END of the string
 delivered by \input@path?
 To give a concrete example: When I open document test-01.lyx with LyX in
 the directory

 /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

 and compile my document it shows the correct path

 /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/

 Fine.

 What I would like to derive from this string is
 /.../Lyx-Tests/Inputpath/blam/ ;-)
 See what I mean?

 My LaTeX experience told me the need for \makeat...,
 but this transformation I'm not able to do in LaTeX.


 Any help appreciated


 Cheers

 Hellmut


 
 kludge solution, if you know how deep your paths are:
 
 \def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
 \def\removeprefix#1{\expandafter\removeprefixx#1}
 
 \removeprefix{\input@path}
 
Hi list,
I have to add one aspect to the functionality I'm looking for:
Since I'm used to use directory names which contain underscores ('_') my
python code should read:

leo@sylhepta ~ $ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type help, copyright, credits or license for more information.
 def shorten_path(path, len):
...   return '/.../' + '/'.join(path.split(
  '/')[-len:]).replace('_','\_')
...
 shorten_path('/home/leo/leo/Test_01/abc',2)
'/.../Test\_01/abc'


TIA and Best regards

Hellmut

-- 
Dr. Hellmut Weber m...@hellmutweber.de
Degenfeldstraße 2 tel   +49-89-3081172
D-80803 München-Schwabing mobil +49-172-8450321
please: No DOCs, no PPTs. why: tinyurl.com/cbgq



Re: LaTeX question w.r.t \input@path

2011-04-05 Thread Julien Rioux

On 05/04/2011 7:21 PM, Hellmut Weber wrote:

Am 04.04.2011 23:32, schrieb Julien Rioux:

On 04/04/2011 3:47 PM, Hellmut Weber wrote:

Hi list,
recently in another post I found the internal LaTeX macro

\input@path

mentioned. Putting this (surrounded by \makeatletter and \makeatother)
in an ERT eventually gives me the correct path to my LyX document as
string in the document.

S many thanks to the poster of that other message (soem days
ago) !

Here is now my question to the LaTeX gurus:
How can I define a LaTeX macro which gives me the END of the string
delivered by \input@path?
To give a concrete example: When I open document test-01.lyx with LyX in
the directory

 /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

and compile my document it shows the correct path

 /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/

Fine.

What I would like to derive from this string is
 /.../Lyx-Tests/Inputpath/blam/ ;-)
See what I mean?

My LaTeX experience told me the need for \makeat...,
but this transformation I'm not able to do in LaTeX.


Any help appreciated


Cheers

Hellmut




kludge solution, if you know how deep your paths are:

\def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
\def\removeprefix#1{\expandafter\removeprefixx#1}

\removeprefix{\input@path}


Hi list,
I have to add one aspect to the functionality I'm looking for:
Since I'm used to use directory names which contain underscores ('_') my
python code should read:

leo@sylhepta ~ $ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type help, copyright, credits or license for more information.

def shorten_path(path, len):

...   return '/.../' + '/'.join(path.split(
   '/')[-len:]).replace('_','\_')
...

shorten_path('/home/leo/leo/Test_01/abc',2)

'/.../Test\_01/abc'




TIA and Best regards

Hellmut



Hellmut,

You might consider taking your question to a dedicated TeX channel. 
Splitting on / is doable, escaping _ too, but the real hard part about 
your request is this:


[-len:]

In tEx I do not know how to access the last N elements of a list when he 
list length is unknown, although accessing the first N is easy. If you 
know the list length then it's easy as well, but it looks not right for 
your case because the path could be any depth.


Cheers,
Julien


Re: LaTeX question w.r.t \input@path

2011-04-05 Thread Richard Heck

On 04/05/2011 07:28 PM, Julien Rioux wrote:

On 05/04/2011 7:21 PM, Hellmut Weber wrote:

Am 04.04.2011 23:32, schrieb Julien Rioux:

On 04/04/2011 3:47 PM, Hellmut Weber wrote:

Hi list,
recently in another post I found the internal LaTeX macro

\input@path

mentioned. Putting this (surrounded by \makeatletter and \makeatother)
in an ERT eventually gives me the correct path to my LyX document as
string in the document.

S many thanks to the poster of that other message (soem days
ago) !

Here is now my question to the LaTeX gurus:
How can I define a LaTeX macro which gives me the END of the string
delivered by \input@path?
To give a concrete example: When I open document test-01.lyx with 
LyX in

the directory

 /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

and compile my document it shows the correct path

 /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/

Fine.

What I would like to derive from this string is
 /.../Lyx-Tests/Inputpath/blam/ ;-)
See what I mean?

My LaTeX experience told me the need for \makeat...,
but this transformation I'm not able to do in LaTeX.


Any help appreciated


Cheers

Hellmut




kludge solution, if you know how deep your paths are:

\def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
\def\removeprefix#1{\expandafter\removeprefixx#1}

\removeprefix{\input@path}


Hi list,
I have to add one aspect to the functionality I'm looking for:
Since I'm used to use directory names which contain underscores ('_') my
python code should read:

leo@sylhepta ~ $ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type help, copyright, credits or license for more information.

def shorten_path(path, len):

...   return '/.../' + '/'.join(path.split(
   '/')[-len:]).replace('_','\_')
...

shorten_path('/home/leo/leo/Test_01/abc',2)

'/.../Test\_01/abc'




TIA and Best regards

Hellmut



Hellmut,

You might consider taking your question to a dedicated TeX channel. 
Splitting on / is doable, escaping _ too, but the real hard part about 
your request is this:


[-len:]

In tEx I do not know how to access the last N elements of a list when 
he list length is unknown, although accessing the first N is easy. If 
you know the list length then it's easy as well, but it looks not 
right for your case because the path could be any depth.


OK, so this is getting a little off-topic, but the attached kind of 
works, as you can see if you compile it. Unfortunately, it does not work 
with macros, but only with a literal. I.e., this:

\split{hi/there/bob}
works but
\def\tempa{hi/there/bob}
\split{\tempa}
does not work. I do not see why, but perhaps someone else will know.

Richard

\documentclass[a4paper,10pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage{ifthen}
\makeatletter

\def\tempa{}\def\tempb{}
\def\split#1{\@split{#1}#1/@endtoken}
\def\@split#1#2/#3@endtoken{%
  \ifthenelse{\equal{#1}{#2}}{\def\tempa{#1}\def\tempb{}}%
  {\@@split#2/#3@endtoken}}
\def\@@split#1/#2/@endtoken{\def\tempa{#1}\def\tempb{#2}}

\makeatother

\begin{document}
Pure stuff.

\split{hi/there/bob}

\tempa

\tempb

Defined stuff

\def\tempb{hi/there/bob}
\split{\tempb}

\tempa

\tempb

\end{document}


Re: LaTeX question w.r.t \input@path

2011-04-05 Thread Jean-Marc Lasgouttes

Le 04/04/11 21:47, Hellmut Weber a écrit :

Hi list,
recently in another post I found the internal LaTeX macro

   \input@path

mentioned. Putting this (surrounded by \makeatletter and \makeatother)
in an ERT eventually gives me the correct path to my LyX document as
string in the document.


Note that this \input@path is not defined when you export to LaTeX, only 
when running inside LyX. So your code should be robust to that situation...


JMarc


Re: LaTeX question w.r.t \input@path

2011-04-05 Thread Hellmut Weber
Am 04.04.2011 23:32, schrieb Julien Rioux:
 On 04/04/2011 3:47 PM, Hellmut Weber wrote:
 Hi list,
 recently in another post I found the internal LaTeX macro

\input@path

 mentioned. Putting this (surrounded by \makeatletter and \makeatother)
 in an ERT eventually gives me the correct path to my LyX document as
 string in the document.

 S many thanks to the poster of that other message (soem days
 ago) !

 Here is now my question to the LaTeX gurus:
 How can I define a LaTeX macro which gives me the END of the string
 delivered by \input@path?
 To give a concrete example: When I open document test-01.lyx with LyX in
 the directory

 /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

 and compile my document it shows the correct path

 /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/

 Fine.

 What I would like to derive from this string is
 /.../Lyx-Tests/Inputpath/blam/ ;-)
 See what I mean?

 My LaTeX experience told me the need for \makeat...,
 but this transformation I'm not able to do in LaTeX.


 Any help appreciated


 Cheers

 Hellmut


 
 kludge solution, if you know how deep your paths are:
 
 \def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
 \def\removeprefix#1{\expandafter\removeprefixx#1}
 
 \removeprefix{\input@path}
 
Hi Julien,
thanks for your answer ;-)

I think I got the basic idea

BUT i Do NOT know the length the path delivered by \input@path.
To make clear what I'm looking for I put it in python code:

leo@sylhepta ~ $ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type help, copyright, credits or license for more information.
 def shorten_path(path, len):
...   return '/.../' + '/'.join(path.split('/')[-len:])
...
 shorten_path('/home/leo/leo/Test/abc',2)
'/.../Test/abc'


Can this be done in (La)TeX?


Thanks again and thanks to all others who contributed

Best regards

Hellmut

-- 
Dr. Hellmut Weber m...@hellmutweber.de
Degenfeldstraße 2 tel   +49-89-3081172
D-80803 München-Schwabing mobil +49-172-8450321
please: No DOCs, no PPTs. why: tinyurl.com/cbgq


Re: LaTeX question w.r.t \input@path

2011-04-05 Thread Richard Heck

On 04/05/2011 03:20 AM, Hellmut Weber wrote:


To make clear what I'm looking for I put it in python code:

leo@sylhepta ~ $ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type help, copyright, credits or license for more information.

def shorten_path(path, len):

...   return '/.../' + '/'.join(path.split('/')[-len:])
...

shorten_path('/home/leo/leo/Test/abc',2)

'/.../Test/abc'
Can this be done in (La)TeX?


Yes, but it involves magic. This post

http://stackoverflow.com/questions/2402354/split-comma-separated-parameters-in-latex

describes how to split on commas and this one on spaces
http://tex.stackexchange.com/questions/12810/how-do-i-split-a-string
They can both be adapted.

Richard



Re: LaTeX question w.r.t \input@path

2011-04-05 Thread Hellmut Weber
Am 04.04.2011 23:32, schrieb Julien Rioux:
 On 04/04/2011 3:47 PM, Hellmut Weber wrote:
 Hi list,
 recently in another post I found the internal LaTeX macro

\input@path

 mentioned. Putting this (surrounded by \makeatletter and \makeatother)
 in an ERT eventually gives me the correct path to my LyX document as
 string in the document.

 S many thanks to the poster of that other message (soem days
 ago) !

 Here is now my question to the LaTeX gurus:
 How can I define a LaTeX macro which gives me the END of the string
 delivered by \input@path?
 To give a concrete example: When I open document test-01.lyx with LyX in
 the directory

 /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

 and compile my document it shows the correct path

 /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/

 Fine.

 What I would like to derive from this string is
 /.../Lyx-Tests/Inputpath/blam/ ;-)
 See what I mean?

 My LaTeX experience told me the need for \makeat...,
 but this transformation I'm not able to do in LaTeX.


 Any help appreciated


 Cheers

 Hellmut


 
 kludge solution, if you know how deep your paths are:
 
 \def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
 \def\removeprefix#1{\expandafter\removeprefixx#1}
 
 \removeprefix{\input@path}
 
Hi list,
I have to add one aspect to the functionality I'm looking for:
Since I'm used to use directory names which contain underscores ('_') my
python code should read:

leo@sylhepta ~ $ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type help, copyright, credits or license for more information.
 def shorten_path(path, len):
...   return '/.../' + '/'.join(path.split(
  '/')[-len:]).replace('_','\_')
...
 shorten_path('/home/leo/leo/Test_01/abc',2)
'/.../Test\_01/abc'


TIA and Best regards

Hellmut

-- 
Dr. Hellmut Weber m...@hellmutweber.de
Degenfeldstraße 2 tel   +49-89-3081172
D-80803 München-Schwabing mobil +49-172-8450321
please: No DOCs, no PPTs. why: tinyurl.com/cbgq



Re: LaTeX question w.r.t \input@path

2011-04-05 Thread Julien Rioux

On 05/04/2011 7:21 PM, Hellmut Weber wrote:

Am 04.04.2011 23:32, schrieb Julien Rioux:

On 04/04/2011 3:47 PM, Hellmut Weber wrote:

Hi list,
recently in another post I found the internal LaTeX macro

\input@path

mentioned. Putting this (surrounded by \makeatletter and \makeatother)
in an ERT eventually gives me the correct path to my LyX document as
string in the document.

S many thanks to the poster of that other message (soem days
ago) !

Here is now my question to the LaTeX gurus:
How can I define a LaTeX macro which gives me the END of the string
delivered by \input@path?
To give a concrete example: When I open document test-01.lyx with LyX in
the directory

 /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

and compile my document it shows the correct path

 /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/

Fine.

What I would like to derive from this string is
 /.../Lyx-Tests/Inputpath/blam/ ;-)
See what I mean?

My LaTeX experience told me the need for \makeat...,
but this transformation I'm not able to do in LaTeX.


Any help appreciated


Cheers

Hellmut




kludge solution, if you know how deep your paths are:

\def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
\def\removeprefix#1{\expandafter\removeprefixx#1}

\removeprefix{\input@path}


Hi list,
I have to add one aspect to the functionality I'm looking for:
Since I'm used to use directory names which contain underscores ('_') my
python code should read:

leo@sylhepta ~ $ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type help, copyright, credits or license for more information.

def shorten_path(path, len):

...   return '/.../' + '/'.join(path.split(
   '/')[-len:]).replace('_','\_')
...

shorten_path('/home/leo/leo/Test_01/abc',2)

'/.../Test\_01/abc'




TIA and Best regards

Hellmut



Hellmut,

You might consider taking your question to a dedicated TeX channel. 
Splitting on / is doable, escaping _ too, but the real hard part about 
your request is this:


[-len:]

In tEx I do not know how to access the last N elements of a list when he 
list length is unknown, although accessing the first N is easy. If you 
know the list length then it's easy as well, but it looks not right for 
your case because the path could be any depth.


Cheers,
Julien


Re: LaTeX question w.r.t \input@path

2011-04-05 Thread Richard Heck

On 04/05/2011 07:28 PM, Julien Rioux wrote:

On 05/04/2011 7:21 PM, Hellmut Weber wrote:

Am 04.04.2011 23:32, schrieb Julien Rioux:

On 04/04/2011 3:47 PM, Hellmut Weber wrote:

Hi list,
recently in another post I found the internal LaTeX macro

\input@path

mentioned. Putting this (surrounded by \makeatletter and \makeatother)
in an ERT eventually gives me the correct path to my LyX document as
string in the document.

S many thanks to the poster of that other message (soem days
ago) !

Here is now my question to the LaTeX gurus:
How can I define a LaTeX macro which gives me the END of the string
delivered by \input@path?
To give a concrete example: When I open document test-01.lyx with 
LyX in

the directory

 /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

and compile my document it shows the correct path

 /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/

Fine.

What I would like to derive from this string is
 /.../Lyx-Tests/Inputpath/blam/ ;-)
See what I mean?

My LaTeX experience told me the need for \makeat...,
but this transformation I'm not able to do in LaTeX.


Any help appreciated


Cheers

Hellmut




kludge solution, if you know how deep your paths are:

\def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
\def\removeprefix#1{\expandafter\removeprefixx#1}

\removeprefix{\input@path}


Hi list,
I have to add one aspect to the functionality I'm looking for:
Since I'm used to use directory names which contain underscores ('_') my
python code should read:

leo@sylhepta ~ $ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type help, copyright, credits or license for more information.

def shorten_path(path, len):

...   return '/.../' + '/'.join(path.split(
   '/')[-len:]).replace('_','\_')
...

shorten_path('/home/leo/leo/Test_01/abc',2)

'/.../Test\_01/abc'




TIA and Best regards

Hellmut



Hellmut,

You might consider taking your question to a dedicated TeX channel. 
Splitting on / is doable, escaping _ too, but the real hard part about 
your request is this:


[-len:]

In tEx I do not know how to access the last N elements of a list when 
he list length is unknown, although accessing the first N is easy. If 
you know the list length then it's easy as well, but it looks not 
right for your case because the path could be any depth.


OK, so this is getting a little off-topic, but the attached kind of 
works, as you can see if you compile it. Unfortunately, it does not work 
with macros, but only with a literal. I.e., this:

\split{hi/there/bob}
works but
\def\tempa{hi/there/bob}
\split{\tempa}
does not work. I do not see why, but perhaps someone else will know.

Richard

\documentclass[a4paper,10pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage{ifthen}
\makeatletter

\def\tempa{}\def\tempb{}
\def\split#1{\@split{#1}#1/@endtoken}
\def\@split#1#2/#3@endtoken{%
  \ifthenelse{\equal{#1}{#2}}{\def\tempa{#1}\def\tempb{}}%
  {\@@split#2/#3@endtoken}}
\def\@@split#1/#2/@endtoken{\def\tempa{#1}\def\tempb{#2}}

\makeatother

\begin{document}
Pure stuff.

\split{hi/there/bob}

\tempa

\tempb

Defined stuff

\def\tempb{hi/there/bob}
\split{\tempb}

\tempa

\tempb

\end{document}


Re: LaTeX question w.r.t \input@path

2011-04-05 Thread Jean-Marc Lasgouttes

Le 04/04/11 21:47, Hellmut Weber a écrit :

Hi list,
recently in another post I found the internal LaTeX macro

   \input@path

mentioned. Putting this (surrounded by \makeatletter and \makeatother)
in an ERT eventually gives me the correct path to my LyX document as
string in the document.


Note that this \input@path is not defined when you export to LaTeX, only 
when running inside LyX. So your code should be robust to that situation...


JMarc


Re: LaTeX question w.r.t \input@path

2011-04-05 Thread Hellmut Weber
Am 04.04.2011 23:32, schrieb Julien Rioux:
> On 04/04/2011 3:47 PM, Hellmut Weber wrote:
>> Hi list,
>> recently in another post I found the internal LaTeX macro
>>
>>\input@path
>>
>> mentioned. Putting this (surrounded by \makeatletter and \makeatother)
>> in an ERT eventually gives me the correct path to my LyX document as
>> string in the document.
>>
>> S many thanks to the poster of that other message (soem days
>> ago) !
>>
>> Here is now my question to the LaTeX gurus:
>> How can I define a LaTeX macro which gives me the END of the string
>> delivered by \input@path?
>> To give a concrete example: When I open document test-01.lyx with LyX in
>> the directory
>>
>> /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam
>>
>> and compile my document it shows the correct path
>>
>> /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/
>>
>> Fine.
>>
>> What I would like to derive from this string is
>> /.../Lyx-Tests/Inputpath/blam/ ;-)
>> See what I mean?
>>
>> My LaTeX experience told me the need for \makeat...,
>> but this transformation I'm not able to do in LaTeX.
>>
>>
>> Any help appreciated
>>
>>
>> Cheers
>>
>> Hellmut
>>
>>
> 
> kludge solution, if you know how deep your paths are:
> 
> \def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
> \def\removeprefix#1{\expandafter\removeprefixx#1}
> 
> \removeprefix{\input@path}
> 
Hi Julien,
thanks for your answer ;-)

I think I got the basic idea

BUT i Do NOT know the length the path delivered by \input@path.
To make clear what I'm looking for I put it in python code:

leo@sylhepta ~ $ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def shorten_path(path, len):
...   return '/.../' + '/'.join(path.split('/')[-len:])
...
>>> shorten_path('/home/leo/leo/Test/abc',2)
'/.../Test/abc'
>>>

Can this be done in (La)TeX?


Thanks again and thanks to all others who contributed

Best regards

Hellmut

-- 
Dr. Hellmut Weber m...@hellmutweber.de
Degenfeldstraße 2 tel   +49-89-3081172
D-80803 München-Schwabing mobil +49-172-8450321
please: No DOCs, no PPTs. why: tinyurl.com/cbgq


Re: LaTeX question w.r.t \input@path

2011-04-05 Thread Richard Heck

On 04/05/2011 03:20 AM, Hellmut Weber wrote:


To make clear what I'm looking for I put it in python code:

leo@sylhepta ~ $ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.

def shorten_path(path, len):

...   return '/.../' + '/'.join(path.split('/')[-len:])
...

shorten_path('/home/leo/leo/Test/abc',2)

'/.../Test/abc'
Can this be done in (La)TeX?


Yes, but it involves magic. This post

http://stackoverflow.com/questions/2402354/split-comma-separated-parameters-in-latex

describes how to split on commas and this one on spaces
http://tex.stackexchange.com/questions/12810/how-do-i-split-a-string
They can both be adapted.

Richard



Re: LaTeX question w.r.t \input@path

2011-04-05 Thread Hellmut Weber
Am 04.04.2011 23:32, schrieb Julien Rioux:
> On 04/04/2011 3:47 PM, Hellmut Weber wrote:
>> Hi list,
>> recently in another post I found the internal LaTeX macro
>>
>>\input@path
>>
>> mentioned. Putting this (surrounded by \makeatletter and \makeatother)
>> in an ERT eventually gives me the correct path to my LyX document as
>> string in the document.
>>
>> S many thanks to the poster of that other message (soem days
>> ago) !
>>
>> Here is now my question to the LaTeX gurus:
>> How can I define a LaTeX macro which gives me the END of the string
>> delivered by \input@path?
>> To give a concrete example: When I open document test-01.lyx with LyX in
>> the directory
>>
>> /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam
>>
>> and compile my document it shows the correct path
>>
>> /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/
>>
>> Fine.
>>
>> What I would like to derive from this string is
>> /.../Lyx-Tests/Inputpath/blam/ ;-)
>> See what I mean?
>>
>> My LaTeX experience told me the need for \makeat...,
>> but this transformation I'm not able to do in LaTeX.
>>
>>
>> Any help appreciated
>>
>>
>> Cheers
>>
>> Hellmut
>>
>>
> 
> kludge solution, if you know how deep your paths are:
> 
> \def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
> \def\removeprefix#1{\expandafter\removeprefixx#1}
> 
> \removeprefix{\input@path}
> 
Hi list,
I have to add one aspect to the functionality I'm looking for:
Since I'm used to use directory names which contain underscores ('_') my
python code should read:

leo@sylhepta ~ $ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def shorten_path(path, len):
...   return '/.../' + '/'.join(path.split(
  '/')[-len:]).replace('_','\_')
...
>>> shorten_path('/home/leo/leo/Test_01/abc',2)
'/.../Test\_01/abc'
>>>

TIA and Best regards

Hellmut

-- 
Dr. Hellmut Weber m...@hellmutweber.de
Degenfeldstraße 2 tel   +49-89-3081172
D-80803 München-Schwabing mobil +49-172-8450321
please: No DOCs, no PPTs. why: tinyurl.com/cbgq



Re: LaTeX question w.r.t \input@path

2011-04-05 Thread Julien Rioux

On 05/04/2011 7:21 PM, Hellmut Weber wrote:

Am 04.04.2011 23:32, schrieb Julien Rioux:

On 04/04/2011 3:47 PM, Hellmut Weber wrote:

Hi list,
recently in another post I found the internal LaTeX macro

\input@path

mentioned. Putting this (surrounded by \makeatletter and \makeatother)
in an ERT eventually gives me the correct path to my LyX document as
string in the document.

S many thanks to the poster of that other message (soem days
ago) !

Here is now my question to the LaTeX gurus:
How can I define a LaTeX macro which gives me the END of the string
delivered by \input@path?
To give a concrete example: When I open document test-01.lyx with LyX in
the directory

 /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

and compile my document it shows the correct path

 /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/

Fine.

What I would like to derive from this string is
 /.../Lyx-Tests/Inputpath/blam/ ;-)
See what I mean?

My LaTeX experience told me the need for \makeat...,
but this transformation I'm not able to do in LaTeX.


Any help appreciated


Cheers

Hellmut




kludge solution, if you know how deep your paths are:

\def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
\def\removeprefix#1{\expandafter\removeprefixx#1}

\removeprefix{\input@path}


Hi list,
I have to add one aspect to the functionality I'm looking for:
Since I'm used to use directory names which contain underscores ('_') my
python code should read:

leo@sylhepta ~ $ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.

def shorten_path(path, len):

...   return '/.../' + '/'.join(path.split(
   '/')[-len:]).replace('_','\_')
...

shorten_path('/home/leo/leo/Test_01/abc',2)

'/.../Test\_01/abc'




TIA and Best regards

Hellmut



Hellmut,

You might consider taking your question to a dedicated TeX channel. 
Splitting on / is doable, escaping _ too, but the real hard part about 
your request is this:


[-len:]

In tEx I do not know how to access the last N elements of a list when he 
list length is unknown, although accessing the first N is easy. If you 
know the list length then it's easy as well, but it looks not right for 
your case because the path could be any depth.


Cheers,
Julien


Re: LaTeX question w.r.t \input@path

2011-04-05 Thread Richard Heck

On 04/05/2011 07:28 PM, Julien Rioux wrote:

On 05/04/2011 7:21 PM, Hellmut Weber wrote:

Am 04.04.2011 23:32, schrieb Julien Rioux:

On 04/04/2011 3:47 PM, Hellmut Weber wrote:

Hi list,
recently in another post I found the internal LaTeX macro

\input@path

mentioned. Putting this (surrounded by \makeatletter and \makeatother)
in an ERT eventually gives me the correct path to my LyX document as
string in the document.

S many thanks to the poster of that other message (soem days
ago) !

Here is now my question to the LaTeX gurus:
How can I define a LaTeX macro which gives me the END of the string
delivered by \input@path?
To give a concrete example: When I open document test-01.lyx with 
LyX in

the directory

 /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

and compile my document it shows the correct path

 /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/

Fine.

What I would like to derive from this string is
 /.../Lyx-Tests/Inputpath/blam/ ;-)
See what I mean?

My LaTeX experience told me the need for \makeat...,
but this transformation I'm not able to do in LaTeX.


Any help appreciated


Cheers

Hellmut




kludge solution, if you know how deep your paths are:

\def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
\def\removeprefix#1{\expandafter\removeprefixx#1}

\removeprefix{\input@path}


Hi list,
I have to add one aspect to the functionality I'm looking for:
Since I'm used to use directory names which contain underscores ('_') my
python code should read:

leo@sylhepta ~ $ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.

def shorten_path(path, len):

...   return '/.../' + '/'.join(path.split(
   '/')[-len:]).replace('_','\_')
...

shorten_path('/home/leo/leo/Test_01/abc',2)

'/.../Test\_01/abc'




TIA and Best regards

Hellmut



Hellmut,

You might consider taking your question to a dedicated TeX channel. 
Splitting on / is doable, escaping _ too, but the real hard part about 
your request is this:


[-len:]

In tEx I do not know how to access the last N elements of a list when 
he list length is unknown, although accessing the first N is easy. If 
you know the list length then it's easy as well, but it looks not 
right for your case because the path could be any depth.


OK, so this is getting a little off-topic, but the attached kind of 
works, as you can see if you compile it. Unfortunately, it does not work 
with macros, but only with a literal. I.e., this:

\split{hi/there/bob}
works but
\def\tempa{hi/there/bob}
\split{\tempa}
does not work. I do not see why, but perhaps someone else will know.

Richard

\documentclass[a4paper,10pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage{ifthen}
\makeatletter

\def\tempa{}\def\tempb{}
\def\split#1{\@split{#1}#1/@endtoken}
\def\@split#1#2/#3@endtoken{%
  \ifthenelse{\equal{#1}{#2}}{\def\tempa{#1}\def\tempb{}}%
  {\@@split#2/#3@endtoken}}
\def\@@split#1/#2/@endtoken{\def\tempa{#1}\def\tempb{#2}}

\makeatother

\begin{document}
Pure stuff.

\split{hi/there/bob}

\tempa

\tempb

Defined stuff

\def\tempb{hi/there/bob}
\split{\tempb}

\tempa

\tempb

\end{document}


LaTeX question w.r.t \input@path

2011-04-04 Thread Hellmut Weber
Hi list,
recently in another post I found the internal LaTeX macro

  \input@path

mentioned. Putting this (surrounded by \makeatletter and \makeatother)
in an ERT eventually gives me the correct path to my LyX document as
string in the document.

S many thanks to the poster of that other message (soem days ago) !

Here is now my question to the LaTeX gurus:
How can I define a LaTeX macro which gives me the END of the string
delivered by \input@path?
To give a concrete example: When I open document test-01.lyx with LyX in
the directory

   /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

and compile my document it shows the correct path

   /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/

Fine.

What I would like to derive from this string is
   /.../Lyx-Tests/Inputpath/blam/ ;-)
See what I mean?

My LaTeX experience told me the need for \makeat...,
but this transformation I'm not able to do in LaTeX.


Any help appreciated


Cheers

Hellmut


-- 
Dr. Hellmut Weber m...@hellmutweber.de
Degenfeldstraße 2 tel   +49-89-3081172
D-80803 München-Schwabing mobil +49-172-8450321
please: No DOCs, no PPTs. why: tinyurl.com/cbgq


Re: LaTeX question w.r.t \input@path

2011-04-04 Thread Julien Rioux

On 04/04/2011 3:47 PM, Hellmut Weber wrote:

Hi list,
recently in another post I found the internal LaTeX macro

   \input@path

mentioned. Putting this (surrounded by \makeatletter and \makeatother)
in an ERT eventually gives me the correct path to my LyX document as
string in the document.

S many thanks to the poster of that other message (soem days ago) !

Here is now my question to the LaTeX gurus:
How can I define a LaTeX macro which gives me the END of the string
delivered by \input@path?
To give a concrete example: When I open document test-01.lyx with LyX in
the directory

/home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

and compile my document it shows the correct path

/home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/

Fine.

What I would like to derive from this string is
/.../Lyx-Tests/Inputpath/blam/ ;-)
See what I mean?

My LaTeX experience told me the need for \makeat...,
but this transformation I'm not able to do in LaTeX.


Any help appreciated


Cheers

Hellmut




kludge solution, if you know how deep your paths are:

\def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
\def\removeprefix#1{\expandafter\removeprefixx#1}

\removeprefix{\input@path}

--
Julien



Re: LaTeX question w.r.t \input@path

2011-04-04 Thread Julien Rioux

On 04/04/2011 5:32 PM, Julien Rioux wrote:

On 04/04/2011 3:47 PM, Hellmut Weber wrote:

Hi list,
recently in another post I found the internal LaTeX macro

\input@path

mentioned. Putting this (surrounded by \makeatletter and \makeatother)
in an ERT eventually gives me the correct path to my LyX document as
string in the document.

S many thanks to the poster of that other message (soem days
ago) !

Here is now my question to the LaTeX gurus:
How can I define a LaTeX macro which gives me the END of the string
delivered by \input@path?
To give a concrete example: When I open document test-01.lyx with LyX in
the directory

/home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

and compile my document it shows the correct path

/home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/

Fine.

What I would like to derive from this string is
/.../Lyx-Tests/Inputpath/blam/ ;-)
See what I mean?

My LaTeX experience told me the need for \makeat...,
but this transformation I'm not able to do in LaTeX.


Any help appreciated


Cheers

Hellmut




kludge solution, if you know how deep your paths are:

\def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
\def\removeprefix#1{\expandafter\removeprefixx#1}

\removeprefix{\input@path}



(...will not work with windows-style paths.
If you need that remove the leading / after removeprefixx)

--
Julien



Re: LaTeX question w.r.t \input@path

2011-04-04 Thread Richard Heck

On 04/04/2011 05:32 PM, Julien Rioux wrote:


kludge solution, if you know how deep your paths are:

\def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
\def\removeprefix#1{\expandafter\removeprefixx#1}

Can you explain the point of the \expandafter? I see this often, but 
don't understand it.


rh



Re: LaTeX question w.r.t \input@path

2011-04-04 Thread Julien Rioux

On 04/04/2011 5:54 PM, Richard Heck wrote:

On 04/04/2011 05:32 PM, Julien Rioux wrote:


kludge solution, if you know how deep your paths are:

\def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
\def\removeprefix#1{\expandafter\removeprefixx#1}


Can you explain the point of the \expandafter? I see this often, but
don't understand it.

rh



\expandafter\foo\bar tells TeX to expand \bar before expanding \foo

in this case:

first,
expand \input@path to /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

second,
parse /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam using /#1/#2/#3/#4/#5



LaTeX question w.r.t \input@path

2011-04-04 Thread Hellmut Weber
Hi list,
recently in another post I found the internal LaTeX macro

  \input@path

mentioned. Putting this (surrounded by \makeatletter and \makeatother)
in an ERT eventually gives me the correct path to my LyX document as
string in the document.

S many thanks to the poster of that other message (soem days ago) !

Here is now my question to the LaTeX gurus:
How can I define a LaTeX macro which gives me the END of the string
delivered by \input@path?
To give a concrete example: When I open document test-01.lyx with LyX in
the directory

   /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

and compile my document it shows the correct path

   /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/

Fine.

What I would like to derive from this string is
   /.../Lyx-Tests/Inputpath/blam/ ;-)
See what I mean?

My LaTeX experience told me the need for \makeat...,
but this transformation I'm not able to do in LaTeX.


Any help appreciated


Cheers

Hellmut


-- 
Dr. Hellmut Weber m...@hellmutweber.de
Degenfeldstraße 2 tel   +49-89-3081172
D-80803 München-Schwabing mobil +49-172-8450321
please: No DOCs, no PPTs. why: tinyurl.com/cbgq


Re: LaTeX question w.r.t \input@path

2011-04-04 Thread Julien Rioux

On 04/04/2011 3:47 PM, Hellmut Weber wrote:

Hi list,
recently in another post I found the internal LaTeX macro

   \input@path

mentioned. Putting this (surrounded by \makeatletter and \makeatother)
in an ERT eventually gives me the correct path to my LyX document as
string in the document.

S many thanks to the poster of that other message (soem days ago) !

Here is now my question to the LaTeX gurus:
How can I define a LaTeX macro which gives me the END of the string
delivered by \input@path?
To give a concrete example: When I open document test-01.lyx with LyX in
the directory

/home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

and compile my document it shows the correct path

/home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/

Fine.

What I would like to derive from this string is
/.../Lyx-Tests/Inputpath/blam/ ;-)
See what I mean?

My LaTeX experience told me the need for \makeat...,
but this transformation I'm not able to do in LaTeX.


Any help appreciated


Cheers

Hellmut




kludge solution, if you know how deep your paths are:

\def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
\def\removeprefix#1{\expandafter\removeprefixx#1}

\removeprefix{\input@path}

--
Julien



Re: LaTeX question w.r.t \input@path

2011-04-04 Thread Julien Rioux

On 04/04/2011 5:32 PM, Julien Rioux wrote:

On 04/04/2011 3:47 PM, Hellmut Weber wrote:

Hi list,
recently in another post I found the internal LaTeX macro

\input@path

mentioned. Putting this (surrounded by \makeatletter and \makeatother)
in an ERT eventually gives me the correct path to my LyX document as
string in the document.

S many thanks to the poster of that other message (soem days
ago) !

Here is now my question to the LaTeX gurus:
How can I define a LaTeX macro which gives me the END of the string
delivered by \input@path?
To give a concrete example: When I open document test-01.lyx with LyX in
the directory

/home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

and compile my document it shows the correct path

/home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/

Fine.

What I would like to derive from this string is
/.../Lyx-Tests/Inputpath/blam/ ;-)
See what I mean?

My LaTeX experience told me the need for \makeat...,
but this transformation I'm not able to do in LaTeX.


Any help appreciated


Cheers

Hellmut




kludge solution, if you know how deep your paths are:

\def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
\def\removeprefix#1{\expandafter\removeprefixx#1}

\removeprefix{\input@path}



(...will not work with windows-style paths.
If you need that remove the leading / after removeprefixx)

--
Julien



Re: LaTeX question w.r.t \input@path

2011-04-04 Thread Richard Heck

On 04/04/2011 05:32 PM, Julien Rioux wrote:


kludge solution, if you know how deep your paths are:

\def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
\def\removeprefix#1{\expandafter\removeprefixx#1}

Can you explain the point of the \expandafter? I see this often, but 
don't understand it.


rh



Re: LaTeX question w.r.t \input@path

2011-04-04 Thread Julien Rioux

On 04/04/2011 5:54 PM, Richard Heck wrote:

On 04/04/2011 05:32 PM, Julien Rioux wrote:


kludge solution, if you know how deep your paths are:

\def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
\def\removeprefix#1{\expandafter\removeprefixx#1}


Can you explain the point of the \expandafter? I see this often, but
don't understand it.

rh



\expandafter\foo\bar tells TeX to expand \bar before expanding \foo

in this case:

first,
expand \input@path to /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

second,
parse /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam using /#1/#2/#3/#4/#5



LaTeX question w.r.t \input@path

2011-04-04 Thread Hellmut Weber
Hi list,
recently in another post I found the internal LaTeX macro

  \input@path

mentioned. Putting this (surrounded by \makeatletter and \makeatother)
in an ERT eventually gives me the correct path to my LyX document as
string in the document.

S many thanks to the poster of that other message (soem days ago) !

Here is now my question to the LaTeX gurus:
How can I define a LaTeX macro which gives me the END of the string
delivered by \input@path?
To give a concrete example: When I open document test-01.lyx with LyX in
the directory

   /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

and compile my document it shows the correct path

   /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/

Fine.

What I would like to derive from this string is
   /.../Lyx-Tests/Inputpath/blam/ ;-)
See what I mean?

My LaTeX experience told me the need for \makeat...,
but this transformation I'm not able to do in LaTeX.


Any help appreciated


Cheers

Hellmut


-- 
Dr. Hellmut Weber m...@hellmutweber.de
Degenfeldstraße 2 tel   +49-89-3081172
D-80803 München-Schwabing mobil +49-172-8450321
please: No DOCs, no PPTs. why: tinyurl.com/cbgq


Re: LaTeX question w.r.t \input@path

2011-04-04 Thread Julien Rioux

On 04/04/2011 3:47 PM, Hellmut Weber wrote:

Hi list,
recently in another post I found the internal LaTeX macro

   \input@path

mentioned. Putting this (surrounded by \makeatletter and \makeatother)
in an ERT eventually gives me the correct path to my LyX document as
string in the document.

S many thanks to the poster of that other message (soem days ago) !

Here is now my question to the LaTeX gurus:
How can I define a LaTeX macro which gives me the END of the string
delivered by \input@path?
To give a concrete example: When I open document test-01.lyx with LyX in
the directory

/home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

and compile my document it shows the correct path

/home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/

Fine.

What I would like to derive from this string is
/.../Lyx-Tests/Inputpath/blam/ ;-)
See what I mean?

My LaTeX experience told me the need for \makeat...,
but this transformation I'm not able to do in LaTeX.


Any help appreciated


Cheers

Hellmut




kludge solution, if you know how deep your paths are:

\def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
\def\removeprefix#1{\expandafter\removeprefixx#1}

\removeprefix{\input@path}

--
Julien



Re: LaTeX question w.r.t \input@path

2011-04-04 Thread Julien Rioux

On 04/04/2011 5:32 PM, Julien Rioux wrote:

On 04/04/2011 3:47 PM, Hellmut Weber wrote:

Hi list,
recently in another post I found the internal LaTeX macro

\input@path

mentioned. Putting this (surrounded by \makeatletter and \makeatother)
in an ERT eventually gives me the correct path to my LyX document as
string in the document.

S many thanks to the poster of that other message (soem days
ago) !

Here is now my question to the LaTeX gurus:
How can I define a LaTeX macro which gives me the END of the string
delivered by \input@path?
To give a concrete example: When I open document test-01.lyx with LyX in
the directory

/home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

and compile my document it shows the correct path

/home/leo/leo/Tests/Lyx-Tests/Inputpath/blam/

Fine.

What I would like to derive from this string is
/.../Lyx-Tests/Inputpath/blam/ ;-)
See what I mean?

My LaTeX experience told me the need for \makeat...,
but this transformation I'm not able to do in LaTeX.


Any help appreciated


Cheers

Hellmut




kludge solution, if you know how deep your paths are:

\def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
\def\removeprefix#1{\expandafter\removeprefixx#1}

\removeprefix{\input@path}



(...will not work with windows-style paths.
If you need that remove the leading / after removeprefixx)

--
Julien



Re: LaTeX question w.r.t \input@path

2011-04-04 Thread Richard Heck

On 04/04/2011 05:32 PM, Julien Rioux wrote:


kludge solution, if you know how deep your paths are:

\def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
\def\removeprefix#1{\expandafter\removeprefixx#1}

Can you explain the point of the \expandafter? I see this often, but 
don't understand it.


rh



Re: LaTeX question w.r.t \input@path

2011-04-04 Thread Julien Rioux

On 04/04/2011 5:54 PM, Richard Heck wrote:

On 04/04/2011 05:32 PM, Julien Rioux wrote:


kludge solution, if you know how deep your paths are:

\def\removeprefixx/#1/#2/#3/#4/#5{Your path is /.../#5}
\def\removeprefix#1{\expandafter\removeprefixx#1}


Can you explain the point of the \expandafter? I see this often, but
don't understand it.

rh



\expandafter\foo\bar tells TeX to expand \bar before expanding \foo

in this case:

first,
expand \input@path to /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam

second,
parse /home/leo/leo/Tests/Lyx-Tests/Inputpath/blam using /#1/#2/#3/#4/#5