2014 dxdy logo

Научный форум dxdy

Математика, Физика, Computer Science, Machine Learning, LaTeX, Механика и Техника, Химия,
Биология и Медицина, Экономика и Финансовая Математика, Гуманитарные науки




На страницу 1, 2  След.
 
 python in latex
Сообщение28.03.2017, 18:12 
Всем привет. Возникла потребность в использование Python в Latex. Для этого я загрузил файл python.sty и вставил в рабочий каталог. Далее я ввожу код:
Используется синтаксис LaTeX
\documentclass[14pt]{extarticle}
\usepackage{python}
\begin{document}
        \begin{python}
                print 'hello world!'
        \end{python}
\end{document}
 

После компиляции возникает ошибка:
1)I can't find file `document.py.out'. \end{python}
2)Emergency stop. \end{python}
Что делать?
У меня стоит:
windows 8.1
Tex LIfe
TeXstudio

 
 
 
 Re: python in latex
Сообщение28.03.2017, 22:21 
Аватара пользователя
Работает. Небось опять гоните без --shell-escape. И это не Tex LIfe, a TeXLive.

 
 
 
 Re: python in latex
Сообщение28.03.2017, 23:26 
У меня в PdfLaTex(в настройках TeXstudio) стоит:
pdflatex -shell-escape -synctex=1 -interaction=nonstopmode %.tex

 
 
 
 Re: python in latex
Сообщение29.03.2017, 01:03 
Аватара пользователя
Вообще-то --shell-escape с двумя черточками.

Какие файлы document.py.*** созданы в той директории?

В частности: document.py?
LaTeX должен его записать, а потом подать через терминал команду питону: python document.py > document.py.out , и в свою очередь использовать document.py.out для процессирования; по крайней мере так оно работает на нормальных OS. Т.ч. отслеживайте шаги

 
 
 
 Re: python in latex
Сообщение29.03.2017, 07:29 

(Судя по хелпу команды под Windows, можно и с одной черточкой)

код: [ скачать ] [ спрятать ]
Используется синтаксис PowerShell
pdflatex --help
Usage: pdftex [OPTION]... [TEXNAME[.tex]] [COMMANDS]
   or: pdftex [OPTION]... \FIRST-LINE
   or: pdftex [OPTION]... &FMT ARGS
  Run pdfTeX on TEXNAME, usually creating TEXNAME.pdf.
  Any remaining COMMANDS are processed as pdfTeX input, after TEXNAME is read.
  If the first line of TEXNAME is %&FMT, and FMT is an existing .fmt file,
  use it.  Else use `NAME.fmt', where NAME is the program invocation name,
  most commonly `pdftex'.

  Alternatively, if the first non-option argument begins with a backslash,
  interpret all non-option arguments as a line of pdfTeX input.

  Alternatively, if the first non-option argument begins with a &, the
  next word is taken as the FMT to read, overriding all else.  Any
  remaining arguments are processed as above.

  If no arguments or options are specified, prompt for input.

-draftmode              switch on draft mode (generates no output PDF)
-enc                    enable encTeX extensions such as \mubyte
-etex                   enable e-TeX extensions
[-no]-file-line-error   disable/enable file:line:error style messages
-fmt=FMTNAME            use FMTNAME instead of program name or a %& line
-halt-on-error          stop processing at the first error
-ini                    be pdfinitex, for dumping formats; this is implicitly
                          true if the program name is `pdfinitex'
-interaction=STRING     set interaction mode (STRING=batchmode/nonstopmode/
                          scrollmode/errorstopmode)
-ipc                    send DVI output to a socket as well as the usual
                          output file
-ipc-start              as -ipc, and also start the server at the other end
-jobname=STRING         set the job name to STRING
-kpathsea-debug=NUMBER  set path searching debugging flags according to
                          the bits of NUMBER
[-no]-mktex=FMT         disable/enable mktexFMT generation (FMT=tex/tfm/pk)
-mltex                  enable MLTeX extensions such as \charsubdef
-output-comment=STRING  use STRING for DVI file comment instead of date
                          (no effect for PDF)
-output-directory=DIR   use existing DIR as the directory to write files in
-output-format=FORMAT   use FORMAT for job output; FORMAT is `dvi' or `pdf'
[-no]-parse-first-line  disable/enable parsing of first line of input file
-progname=STRING        set program (and fmt) name to STRING
-recorder               enable filename recorder
[-no]-shell-escape      disable/enable \write18{SHELL COMMAND}
-shell-restricted       enable restricted \write18
-src-specials           insert source specials into the DVI file
-src-specials=WHERE     insert source specials in certain places of
                          the DVI file. WHERE is a comma-separated value
                          list: cr display hbox math par parend vbox
-synctex=NUMBER         generate SyncTeX data for previewers if nonzero
-translate-file=TCXNAME use the TCX file TCXNAME
-8bit                   make all characters printable by default
-help                   display this help and exit
-version                output version information and exit

pdfTeX home page: <http://pdftex.org>

Email bug reports to pdftex@tug.org.

 
 
 
 Re: python in latex
Сообщение29.03.2017, 07:35 
Аватара пользователя
В любом случае следует попытаться пройти все шаги, и, в частности, подавать команды с терминала, без участия фронтэнда, чтобы понять, не в нём ли проблема

 
 
 
 Re: python in latex
Сообщение29.03.2017, 13:27 
я сделал с двумя черточками не помогло.В моем директории создано:
document.aux
document
document.out
document.pdf
document.py
document.pytxcode
document.synctex
document.tex
latex.py
python.sty
README
tex.py
Я не понял, что вы имели в виду "подавать команды с терминала, без участия фронтэнда, чтобы понять, не в нём ли проблема"

 
 
 
 Re: python in latex
Сообщение29.03.2017, 13:46 
Аватара пользователя
Какие то странные документы. Откуда-то непонятные tex.py и latex.py.

Откройте document.py и document.out через текстовый редактор, что там?

Я подозреваю, что Ваша (....) ОС вместо document.py.out создает document.out.

См например тут tut.

(Оффтоп)

Удивляет, как это люди, которые не знают базисов, всегда хотят чего-то такого "этакого"

 
 
 
 Re: python in latex
Сообщение29.03.2017, 14:53 
В document.out пусто.
В document.py
print 'hello world!'

 
 
 
 Re: python in latex
Сообщение29.03.2017, 15:02 
Аватара пользователя
guitar15 в сообщении #1204636 писал(а):
В document.out пусто.
В document.py print 'hello world!'

document.py правильный. А вот document.py.out д.б. hello world!
А что будет, если с терминала/консоли в той же директории
Код:
> python document.py

И какая версия питона?

 
 
 
 Re: python in latex
Сообщение29.03.2017, 15:08 
Версия 2.7 питона.
Под терминала/консоли вы имеете в виду командную строку виндовс?

 
 
 
 Re: python in latex
Сообщение29.03.2017, 15:24 
Аватара пользователя
guitar15 в сообщении #1204640 писал(а):
Под терминала/консоли вы имеете в виду командную строку виндовс?
Да

 
 
 
 Re: python in latex
Сообщение29.03.2017, 15:26 
Если через командную строку в директории у меня получилось:
hello world!

 
 
 
 Re: python in latex
Сообщение29.03.2017, 15:33 
Аватара пользователя
ОК. Теперь
Код:
> python document.py > document.py.out

Появится ли document.py.out ? Будет ли он hello world!

 
 
 
 Re: python in latex
Сообщение29.03.2017, 15:46 
Появился document.py.out. Все работает. LaTex компилирует. Спасибо

 
 
 [ Сообщений: 16 ]  На страницу 1, 2  След.


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group