Re: Specifying a path prefix in a LaTeX macro

2013-05-09 Thread Stephen Brooking
> I've tried the same under Windows (I need this to work with LyX under
> Windows), setting an environment variable to point to a path (and
> reconfiguring and restarting LyX just in case), and specifying that path as
> my \filepath, but I still get the same 'I can't write on file
> `/testreq1.tex' error.

Just to add a bit more information, if I try this from a Windows command
prompt I get the same error.
kpsewhich tells me that TEXMFOUTPUT is set to what I think it is set to:

> kpsewhich --var-value=TEXMFOUTPUT
C:\docs

! I can't write on file `C:\docs\testreq1.tex'

If I remove the path setting from my test.tex file so I basically have this:


\newwrite\tempfile
\immediate\openout\tempfile=testreq1.tex
\immediate\write\tempfile{Some text}
\immediate\closeout\tempfile

\input{C:/docs/testreq1.tex}


and set the -output-directory command line option to pdflatex:

> pdflatex -output-directory C:\docs test.tex

It all works, so I know that I can write files to that directory.  (Setting
the -output-directory like this though with LyX has the downside that LyX
then can't find the output PDF file as it isn't in the temp directory that
it expects.)

Also to note, it also works if I set -output-directory to %TEXMFOUTPUT%.

So, any clues as to why this doesn't work when just relying on the
TEXMFOUTPUT variable, without setting -output-directory?

Thanks and regards,

Steve



Re: Problem specifying a new converter

2013-05-09 Thread Stephen Brooking
> $$r The full path to the original LyX file being processed, e.g. 
> D:/Documents/LyX/

Is this supported in Windows?

I tried to update my LaTeX (pdflatex) -> PDF (pdflatex) converter to specify
the output directory (to overcome the problem in my other thread); so it is
specified as this:

pdflatex -output-directory $$r $$i

I get this error:

17:50:13.853: Previewing ...
17:50:13.854: (buffer-view: Ctrl+R)
17:50:14.011: pdflatex -output-directory $$r  "example_raw.tex"
17:50:14.026: pdflatex: The specified directory does not exist.
17:50:14.026: pdflatex: Data: \Temp\lyx_tmpdir.gq5004\lyx_tmpbuf2\$$r

Many thanks,

Steve





Re: Problem specifying a new converter

2013-05-09 Thread Stephen Brooking
> There may not be any pdf->png converter defined, though one could use 
> ImageMagick to define one. A better solution might be to modify the 
> script you have to export something other than PDF. This is probably 
> fairly easy to do.

So I have now updated my script to convert to PNG also, and specified a new
converter to use it, and the preview now appears nicely.

Thank you very much.

Steve



Re: Specifying a path prefix in a LaTeX macro

2013-05-09 Thread Stephen Brooking
> > \filepath{c:/docs/}
> 
> Have you tried it with Windows-style path names?

So I changed this to define a \dirsep macro which gives me a backslash. 
Using \textbackslash (and I think escaping the backslash) seemed to insert a
\T1 macro that is undefined.

However, with my \dirsep, I still get the same error.  I've tried this with
a very basic document using pdflatex under unix, and I got the same problem,
albeit with a different outcome:

(./test.aux)
[1{/usr/share/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]pdflatex: Not
writing to /testreq1.tex (openout_any = p).

! I can't write on file `/testreq1.tex'.
 
   \immediate 
l.26 \reqbody{Put some text in the file}

Please type another output file name: 
(/testreq1.tex) [1] (./test.aux) )
Output written on test.pdf (2 pages, 20839 bytes).
Transcript written on test.log.


So at the 'Please type another output file name:' prompt I just hit enter,
and the write to the original filename was successful.  So this appears to
be a security thing; latex is preventing a write to arbitrary files.  But
just confirming at the prompt that you want to write that file is enough?

So in my Unix setup I set the TEXMFOUTPUT environment variable to ,
and the write now seems to go ahead without any complaint, and without
presenting a prompt for a new filename.


I've tried the same under Windows (I need this to work with LyX under
Windows), setting an environment variable to point to a path (and
reconfiguring and restarting LyX just in case), and specifying that path as
my \filepath, but I still get the same 'I can't write on file
`/testreq1.tex' error.

Any thoughts?

Many thanks,

Steve



Re: Specifying a path prefix in a LaTeX macro

2013-05-08 Thread Stephen Brooking
> > \filepath{c:/docs/}
> 
> Have you tried it with Windows-style path names?

Hi Richard,

I have, but I'm not sure I've tried it in the correct way.

\filepath{c:\docs\}

The above would be looking for the macro \docs ?  How should I express the
Windows-style path names?

Thanks and regards,

Steve



Re: Problem specifying a new converter

2013-05-08 Thread Stephen Brooking
> Which doesn't seem to show any error.
> 
> Any other suggestions of what I could try?  Am I doing the right thing in
> trying to get the console output in the command prompt?

Sorry - I wasn't looking high enough up in the debug output.  If I just
select 'Graphics conversion and loading' messages I see this:

..\..\src\Format.cpp (147): will guess format from file extension: vsd -> 
Visio
..\..\..\src\graphics\GraphicsCacheItem.cpp (385): 
The file contains Visio format data.
..\..\..\src\graphics\GraphicsCacheItem.cpp (340): Unable to convert from
Visio to bmp
..\..\..\src\graphics\GraphicsCacheItem.cpp (340): Unable to convert from
Visio to pbm
..\..\..\src\graphics\GraphicsCacheItem.cpp (340): Unable to convert from
Visio to pgm
..\..\..\src\graphics\GraphicsCacheItem.cpp (340): Unable to convert from
Visio to png
..\..\..\src\graphics\GraphicsCacheItem.cpp (340): Unable to convert from
Visio to ppm
..\..\..\src\graphics\GraphicsCacheItem.cpp (340): Unable to convert from
Visio to xbm
..\..\..\src\graphics\GraphicsCacheItem.cpp (340): Unable to convert from
Visio to xpm
..\..\..\src\graphics\GraphicsConverter.cpp (127): Converter c-tor:
from_file:  .vsd
to_file_base: /CacheItem.nf5008
from_format:  Visio
to_format:ppm
..\..\..\src\graphics\GraphicsConverter.cpp (264): build_script ... 
..\..\..\src\graphics\GraphicsConverter.cpp (330):  No converter defined! I
use convertDefault.py

So I need to specify another converter.  I thought that LyX would take the
to-pdf converter I've specified, and then convert the PDF to something it
could preview; is this not the case?

Many thanks,

Steve




Re: Problem specifying a new converter

2013-05-08 Thread Stephen Brooking
> > So I now get my conversion performed OK when I generate the PDF 
> > document, but the preview of the figure in the LyX editing window 
> > still says 'Error converting to loadable format'. Would you be able to 
> > provide me any pointers as to why this is? Is there a log of the 
> > errors that occurred in this process anywhere?
> 
> If you launch LyX from a terminal window, you should see the error messages.

Hi Richard,

Thank you again for the quick response.  I'm running this from a Windows 7
machine.  So I opened a command prompt, and ran the LyX executable.  LyX
opens, but the command completes immediately, and no output is seen.

>From a quick google, to try to get this output within LyX I tried View->View
Messages, and then setting 'Debug messages' to 'All', and I get this when I
right-click->reload on the graphic in my figure:

..\..\src\BufferView.cpp (2850):*** START DRAWING ***
..\..\src\TextMetrics.cpp (2184): main text redraw pit=4 row=0
row_selection=0 full_repaint=1 row_has_changed=0

..\..\src\TextMetrics.cpp (2184): main text redraw pit=14 row=0
row_selection=0 full_repaint=1 row_has_changed=0
..\..\src\BufferView.cpp (2902): 
*** END DRAWING  ***

Which doesn't seem to show any error.

Any other suggestions of what I could try?  Am I doing the right thing in
trying to get the console output in the command prompt?

Many thanks,

Steve



Specifying a path prefix in a LaTeX macro

2013-05-08 Thread Stephen Brooking
Hi,

I'm using LyX 2.0.5.1 on a Windows 7 machine.

I am trying to put together a LyX framework that will allow me to enter some
text, set it to a particular Style, and for the text marked by that Style to
be written to a file.  The filename and path to be specified by other
macros.  The file created would then be included in my document.

(In the interest of brevity I won't go into why I would like to do this.)

With the implementation detailed below, I get an error when I generate the
PDF document:

! I can't write on file `c:/docs/test.tex'.

I have verified that I can generally create files in the c:/docs directory,
so I don't think it's a permissions or existence issue.  I wonder if it's to
do with Windows-style path names?

So for example I have this in my document (this is the source that LyX shows
for the text I've entered with Styles):

\filepath{c:/docs/}
\filename{test}
\filebody{This is the text that should be put into the file}


I've defined this in my document class:

\newcommand\filename[1]{\renewcommand\filename{#1}}
\newcommand\filepath[1]{\renewcommand\filepath{#1}}
\newcommand\filebody[1]{
\newwrite\tempfile
\immediate\openout\tempfile=\filepath\filename
\immediate\write\tempfile{\filename: #1}
\immediate\closeout\tempfile

\input{\filepath\filename}
}


And in my layout file I have:

Style FileName
LatexType Command
LatexName filename
End

Style FileBody
LatexType Command
LatexName filebody
End

Style FilePath
LatexType Command
LatexName filepath
End

Any thoughts about what's going on would be gratefully received.

Thanks in advance,

Steve



Re: Problem specifying a new converter

2013-05-08 Thread Stephen Brooking
> > No? I hesitate to contradict you Richard but in my tinkering with 
> > Python scripts I've run converters using *all* the following:
> > [snip]
> > $$p The full directory path of the LyX temporary directory. On my 
> > Windows system one day this was
> >
> > C:/Users/Andrew/AppData/Local/Temp/lyx_tmpdir.gq2540/lyx_tmpbuf5/
> 
> OK, thanks. This is in the documentation as "the path to the input 
> file", which usually would be the temporary directory. Perhaps that 
> should be clarified.

Many thanks for your replies.  It wasn't the cscript thingy that was
changing the current directory, but actually in the invocation of Visio from
the VBScript (I think).  So in the VBScript I can obtain the current
directory, and add that to the filename(s) to give Visio.

Thank you for the list of the '$$' variables though; they may well come in
useful.  I did try searching for documentation of them but couldn't find them.

So I now get my conversion performed OK when I generate the PDF document,
but the preview of the figure in the LyX editing window still says 'Error
converting to loadable format'.  Would you be able to provide me any
pointers as to why this is?  Is there a log of the errors that occurred in
this process anywhere?

Many thanks,

Steve



Problem specifying a new converter

2013-05-07 Thread Stephen Brooking
Hi,

I have specified a new converter to convert Visio drawings into PDF (using
some VBScript borrowed from elsewhere on the web), but have run into issues.
 My converter is specified like this:

cscript /vsd2pdf.vbs "$$i" "$$o"

When Visio runs, it can't access the file to convert because the current
directory is not the temp directory that LyX created (I'm not familiar
enough with VBScript to know why or where).

So my question is this: is there a '$$' variable that specifies the
temporary directory in use, so that I can form an absolute path to the $$i
and $$o files?

(I'm using LyX version 2.0.5.1 on a Windows 7 platform.)

Many thanks in advance,

Steve