Hi Murat, thanks for replying. My example was only to illustrate that there seems to be a bug when defining converters.

Thanks for reminding me about branches though.

Bogdan.


On 02-Jan-12 6:30 am, Murat Yildizoglu wrote:
Hi Bogdan,

I have not yet used it myself but, it seems that this is a typical
situation to be handled with branches in Lyx, no?
One branch for only the questions and another one for questions and
answers? SO, you can selectively compile the branch that interests you.

2012/1/2 Bogdan <bog...@mentalgate.net <mailto:bog...@mentalgate.net>>

    Actually, I just discovered that the expansion of $$i is put at the
    end of the actual command LyX launches no matter what I use for the
    converter command, e.g. if the converter command is:

    pdflatexna $$i 20 20

    then LyX is actually executing:

    pdflatexna 20 20 sheet.tex

    Nasty :)

    Bogdan.



    On 02-Jan-12 12:08 am, Bogdan wrote:

        As part of my course, I've been traditionally maintaining a problem
        sheet in latex and compile two versions, one with answers, and one
        without. To achieve that, I hide the answers based on whether a
        certain
        variable was defined in latex or not and then compile it
        accordingly:

        with answers: pdflatex sheet.tex
        without answers: pdflatex "\def\noanswers{yes}\input{__sheet.tex}"

        I defined a new converter in LyX do achieve the same but I could
        not do
        it without wrapping the 2nd command in a shell script (I'm using
        windows). What I did:

        - defined a new file format pdf6: PDF (pdflatex-na) with the same
        settings as pdf2: PDF (pdflatex).
        - defined a converter Latex (pdflatex) -> PDF (pdflatex-na) with the
        following for converter: pdflatex "\def\noanswers{yes}\input{$$__i}"

        Checking the lyx preferences file, I see it correctly escaped as:

        \converter "pdflatex" "pdf6" "pdflatex
        \"\\def\\noanswers{yes}\\__input{$$i}\"" "latex=pdflatex"

        However, when I try to use it (update or export) then LyX
        launches the
        converter and keeps waiting for it to terminate. Investigating the
        matter with a task manager like Process Hacker or Process
        Explorer, in
        order to see what command was actually executed, I notice that LyX
        started a cmd shell which in fact executed the following:

        pdflatex "\def\noanswers{yes}\input{ }" sheet.tex

        Note the empty \input{} and the file name sheet.tex at the end,
        instead
        of inside \input{sheet.tex}.

        I tried with the other variables $$b.tex, $$p, $$r etc, to no avail.

        Unless I'm missing something, this looks like a bug. Is there a
        python
        script anywhere that launches the cmd shell? It's probably there
        and I
        could fix it.

        My workaround is to wrap the whole thing in a cmd script
        pdflatexna.bat
        placed in lyx/bin with the contents:

        @pdflatex "\def\noanswers{yes}\input{%~__1}"

        (the %~1 instead of %1 is to strip any double quotes)

        ... and then use the following command for the converter:
        pdflatexna $$i

        Cheers,
        Bogdan.







--
Prof. Murat Yildizoglu

Université Montesquieu Bordeaux IV
GREThA (UMR CNRS 5113)
Avenue LĂ©on Duguit
33608 Pessac cedex
France

Bureau : F-331

yi...@u-bordeaux4.fr <mailto:yi...@u-bordeaux4.fr>

http://yildizoglu.info

http://www.twitter.com/yildizoglu



Reply via email to