help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using fprintf to output a .tex file


From: Ben Abbott
Subject: Re: Using fprintf to output a .tex file
Date: Mon, 17 Jun 2013 03:38:41 +0000 (GMT)



On Jun 16, 2013, at 10:46 PM, bondmatt <address@hidden> wrote:

I have been working on an Octave script that outputs a .tex file to generate
a report with Latex. I tried copying my tex file into my Octave script using
the arrangement below but I have had issues. I started with a file from
someone else so I was aware of the need to replace single backslashes with
double backslashes. Additionally, I found a helpful hint in the forum to
obtain double backslashes (\\ - critical in Latex) by putting four
backslashes (\\\\) in the string to be output with fprintf.

However, I have been unable to get my script to output the Latex file. I see
the error 'error: fprintf: invalid format specified'.

Any suggestions, perhaps better methods I should be considering, would be
greatly appreciated!

Thanks!

A stripped example of the Latex output portion of my script (the last few
lines):

s=['\\end{tabular}\n'];
s=[s '\\end{document}\n'];
file=fopen('report.tex','w');
fprintf(file,s);

If you use single-quotes for your variable "s" there is no need or the double-backslash.  Also, a cell-string array is a better choice for "s".

Try ...

s = {'\end{tabular}', '\end{document}'};
fid = fopen ('report.tex', 'w');
fprintf (fid, "%s\n", s{:})

Ben



reply via email to

[Prev in Thread] Current Thread [Next in Thread]