2
#==============================================================================
5
# DESCRIPTION: A simple TeXmacs interface for TeXgraph
6
# BY : Emmanuel Corcelle (corcelle at gmail dot com)
7
#------------------------------------------------------------------------------
8
# Based on : A simple PSTricks interface for TeXmacs
9
# COPYRIGHT : (C) 2004 Nicolas Ratier (nicolas DOT ratier AT lpmo DOT edu))
10
#------------------------------------------------------------------------------
11
# COPYRIGHT : (C) TeXgraph by Patrick Fradin (pfradin at tuxfamily point org) (http://texgraph.tuxfamily.org/)
12
#------------------------------------------------------------------------------
15
# bash script for interfacing TeXgraph from TeXmacs
16
# needs option --texmacs for compatibility with TeXmacs interface convention and user information
18
# usage within TeXmacs:
19
# =====================
20
# write texgraph-commands within the input line, use as many commands as necessary,
21
# divide them by the "," chararacter, because the ENTER key terminates the input and sends it to TeXgraph.
22
# output is the graph made via TeXgraphCmd, latex, and dvips -E mode.
24
# Temporary file are made in ~/.TeXmacs/system/tmp
25
#------------------------------------------------------------------------------
26
# This software falls under the GNU general public license and comes WITHOUT
27
# ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
28
# If you don't have this file, write to the Free Software Foundation, Inc.,
29
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30
#==============================================================================
32
if [ "$1" != "--texmacs" ]
34
echo tm_texgraph. This script should be started only from TeXmacs.
39
tmp=`echo DATA_BEGIN=X DATA_END=Y DATA_ESCAPE=Z | tr "XYZ" "\002\005\027" `
42
# defining temporary files directory and make it if it doesn't exist
43
TEMP_DIR=~/.TeXmacs/system/tmp
52
# defining primary temp file name
57
echo verbatim:TeXmacs interface to TeXgraph.
58
echo To write LaTeX code inside labels, use \\\\ instead of \\.
59
echo For example, write $\\\\pi$ instead of $\\pi$
62
# prompt-input-texgraph-output loop
66
echo -n channel:prompt
71
# read a line from stdin
74
# begin creation of TeX file
75
echo -E "\documentclass{article}" > $TEMP_FILE.tex
76
echo -E "\usepackage{texgraph}" >> $TEMP_FILE.tex
77
echo -E "\pagestyle{empty}" >> $TEMP_FILE.tex
78
echo -E "\begin{document}" >> $TEMP_FILE.tex
79
echo -E "\begin{texgraph}[export=epsc]" >> $TEMP_FILE.tex
80
echo -E "HideStyle:=dashed," >> $TEMP_FILE.tex
81
echo -E "Marges(0.25,0.25,0.25,0.25)," >> $TEMP_FILE.tex
82
# other commands to initialize the graph can be included here
84
# copy TeXgraph in latex file
85
echo -E $input | tr "~" "\n" | cat >> $TEMP_FILE.tex
88
echo -E "\end{texgraph}" >> $TEMP_FILE.tex
89
echo -E "\end{document}" >> $TEMP_FILE.tex
91
# compile with latex, transform to .eps and cat .eps to TeXmacs.
92
latex --shell-escape --interaction=nonstopmode --draftmode $TEMP_FILE.tex 1> /dev/null 2> tmp_log
93
if [ -s texgraphtmp1.eps ]
102
rm $TEMP_FILE.* texgraphtmp1.* tmp*
111
rm $TEMP_FILE.* texgraphtmp1.* tmp*