LaTeX is pretty common tool for typsetting symbols and formulas (i.e. \alpha, \frac) and I have learned that there are different terminals that support it, of which I especially like tikz which I often use in LaTeX. However those terminals have output as a file only. Is there any terminal or other option that allows using LaTeX commands and still shows the result instantly in a separate window?
Here is what I would do, and have done on occasion. The refresh does not happen "instantly" since pdflatex is far from instantaneous. However it does have the advantage of keeping you inside the gnuplot session as you work on your figure.
# Create a pdf file holding the initial plot
MYFIGURE = "myfigure.tex"
set term tikz standalone
set output MYFIGURE gnuplot> replot; unset out; system("pdflatex myfigure"); set out MYFIGURE
gnuplot> ... tweak the title, layout, colors, whatever
gnuplot> history !replot
plot PLOT1
unset output
# Display the pdf on the screen using whatever the standard pdf viewer
# is on your system. For me (KDE desktop) this is okular.
system("pdflatex myfigure")
system("okular myfigure.pdf &")
# Draw new or updated versions of the figure into the same file
# okular will notice that the file has changed and refresh the display
set out MYFIGURE
set title "Same figure, new title"
replot
unset out; system("pdflatex myfigure")
set out MYFIGURE
set title "Different figure entirely"
splot FOO with pm3d
unset out; system("pdflatex myfigure")
# ... and so on
If you are continually tweaking the layout of the same figure so that the sequence always involves a replot, then putting the sequence on a single line gnuplot command allows you to re-execute in a singe step using gnuplot's history commands or hitting up-arrow a few times to retrieve the command.
For example:
gnuplot> replot; unset out; system("pdflatex myfigure"); set out MYFIGURE
gnuplot> ... tweak the title, layout, colors, whatever ...
gnuplot> history !replot
gnuplot> ... tweak the figure some more ...
gnuplot> history !replot
Note: TeX will want to find the gnuplot support packages in its normal search path. If they are not already present in your TeX installation, you can follow the instructions in the gnuplot source .../term/lua/README (copied here)
Generating style and help file
==============================
To generate the style files and wrapper for the various TeX flavors enter
lua gnuplot-tikz.lua style
on the command line. The files generated should be
t-gnuplot-lua-tikz.tex (Context wrapper)
gnuplot-lua-tikz.tex (plain TeX wrapper)
gnuplot-lua-tikz.sty (LaTeX wrapper)
gnuplot-lua-tikz-common.tex (common definitions)
and can be copied to the appropriate places.
Related
So I have to write my lab report in Italian for my lab class. In class they taught us how to use gnuplot to create graphs, so I'm using it to produce our graphs, which then I need to put in my latex document. The problem is that I have to set the label on the y axes as "velocità", and when I then save the file in ps and convert in pdf the 'à' disappears or is substituted by something else. What I've tried doing is using variations of the commands
set encoding iso_8859_1
set ylabel "velocit\340"
then I saved the plot using set term postscript color, set output "graf.ps", replot, and from the wsl terminal, using ps2pdf, I converted it into a pdf, but when I open the pdf, the letter 'à' doesn't appear anymore, even though it did show in graph previously generated by gnuplot. What should I do? In case, is there another way I can attach the original graph in my latex document?
Gnuplot provides several LaTeX-friendly terminal types. Postscript is not one of them. Postscript's character encodings are idiosyncratic at best. If your goal is to include gnuplot output in latex, then choose a terminal type that is designed for it. Some terminal types (e.g. cairolatex) work only with latex because they depend on latex to do all the text processing. Others (e.g. pdf, png, tikz) produce output that is fully compatible with latex but already has the text embedded in it. It is best to use UTF-8 encoding for everything, including your accented characters. For example:
set term pdf size 7cm,5cm
set output 'myfigure.pdf'
set encoding utf8
set ylabel "velocità"
set xlabel "tempo"
plot [0:10] x**2 title "velocità"
Then in your latex document, something like:
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
...
My TeX document.
\begin{figure}[h]
\includegraphics{myfigure}
\end{figure}
...
As written in the title, I am trying to create a multipage pdf with gnuplots cairolatex terminal.
I am using gnuplot 5.4 in cygwin.
Single page works fine, i.e.
./gnuplot-script
pdflatex plot.tex
However when I plot multiple pages in the gnuplot-script, the output .tex file seems to contain errors ..
E.g. the gnuplot-script
set terminal cairolatex standalone
set output "plot.tex"
plot x
plot x**2
outputs a plot.tex that contains two \documentclass{minimal} and pdflatex then complains with
! LaTeX Error: Can be used only in preamble.
...
l.181 \documentclass
{minimal}
I can workaround this by putting each plot into a new file, but it seems a bit strange that simple multipage output is bugged in this terminal?
Am I missing some special command to start a new page in the cairolatex terminal or something? I don't see anything in the documentation for this ..
If you really need to create a TeX-based multipage pdf file directly from gnuplot, I suggest to use the tikz terminal rather than cairolatex.
set terminal tikz standalone
set output "plot.tex"
plot x
plot x**2
unset output
!pdflatex plot
I am using a single unified LaTeX doc to create problem sets and solutions:
\item What is one plus one?
\begin{soln}
The answer is "two".
\end{soln}
In LaTeX, I define this environment with (simplified):
\NewEnviron{soln}
{
\ifsolutions\expandafter
\BODY
\fi
}
That is, if \solutionsfalse has been defined in LaTeX, it prints:
1. What is one plus one?
and if \solutionstrue has been defined, it prints:
1. What is one plus one?
** The answer is two **
I'm trying to replicate this in pandoc to generate HTML or MD files from the latex input, but I've run against the wall. Pandoc doesn't honor any kind of /if /else /fi statement in LaTeX, I think. Pandoc doesn't honor the comment environment, which would also work with \excludecomment{soln}. So, I can't come up with a shim.tex file that would replicate the 'ignore stuff in the soln environment'.
The next way to go would, I guess, be to do something in luatex that pandoc can talk to, or to define the custom environment to pandoc with a filter? But the documentation for those systems is extremely heavyweight - there's no easy way in.
Can anyone suggest a solution to this?
Ideally, I want to run two different shell commands. Command A should omit all content in the soln environment. Command B, ideally, should turn all regular text blue, and show all content in the soln environment in black color.
(P.S. The xcolor package also seems unsupported in native pandoc, although there is a filter that doesn't work for me.)
Edit
Following comments by #tarleb and #mb21, I guess I have to try to work out how filters work. Again, the documentation here is terrible - it wants you to know everything before you can do anything.
I tried this:
return {
{
RawBlock = function(elem)
print(elem.text)
if starts_with('\\begin{soln}', elem.text) then
return pandoc.RawBlock(elem.format,"SOLN")
else
return elem
end
end,
}
}
and ran it with
pandoc --lua-filter ifdef.lua --mathjax -s hw01.tex -s -o hw01.html
But there is nothing on stdout from the print statement, and my document is unchanged, so the RawBlocks are apparently not processed by the lua filter unless the -f latex+raw_tex flag is passed. But passing those flags means that pandoc doesn't actually process the \include commands in the latex, so my filter wont' see the subdocuments.
Apparently, the answer is "No, pandoc cannot support new latex environment", because it would require modifying the parser. Although the -f latex+raw_tex can disable big parts of the parser, that just means the document is largely unparsed, which isn't what I want.
Please tell me if I'm wrong.
I have the following line in my .vimrc:
autocmd FileType tex map <C-L> :!pdflatex % &<CR>
Now, the binding works fine, however when vim switches over to produces the output of pdflatex, it breaks lines in random places, producing unreadable output and making it very difficult to debug errors. Is there any way to correct this?
If you wanted to accomplish this without anything showing in your vim session you could take a different approach. For example:
au FileType tex map <silent> <expr> <C-L> system("pdflatex ".expand("%"))
See :help <silent> and :help <expr>.
When I use :silent !ls the screen flashes and generally needs a redraw, so this is a workaround.
I have a "project book" which uses LaTeX's \documentclass{report} ("report" is like a more compact version of \documentclass{book}). I would like to include into this book an appendix with the Doxygen-generated API documentation for the software in the project.
I have achieved this by setting Doxygen's config options LATEX_HEADER and LATEX_FOOTER to an empty file. This makes the resulting latex/refman.tex have top level commands like: \section{\-Namespace \-Index}, at which point I can wrap this with a top level document like:
\documentclass{report}
\usepackage{doxygen.sty}
% the "import" package helps to find Doxygen files in the latex/ subdirectory
\usepackage{import}
% [...] title page and the rest of the book
\appendix
\chapter{API reference (generated by Doxygen)
subimport{latex/}{refman.tex}
% [...] final stuff
\end{document}
This works reasonably well and I get doxygen.sty with this special doxygen invocation:
doxygen -w latex /dev/null /dev/null doxygen.sty
One problem is that this puts an "autogenerated" header on the entire document (not just on the doxygen appendix). I can get rid of this by editing doxygen.sty (I also rename it for my inclusion, actually) and commenting out the block that starts with % Setup fancy headings.
At this point I have something I can live with, but I would like to go one step further: the "doxygen" style modifies a lot of other aspects of the LaTeX document style, and I like it less.
So my question is (in two levels of excellence):
What would be a minimal set of LaTeX commands to put in a doxygen.sty file that would nicely render the doxygen appendix but not interfere with the rest of the LaTeX document?
Even better, has someone come up with a way of doing
\usepackage{doxygen_standalone}
% [... until you need doxygen]
\begin{doxygen}
% the stuff you need to insert your auto-generated doxygen API docs,
% for example the \subimport{latex/}{refman.tex} that I showed above
\end{doxygen}
This last approach is one I would consider very clean.
I'm hoping there is a really simple answer, such as "this already exists in doxygen.sty as an option, and you missed it!"
rename doxygen.sty to mydoxygen.sty, then modify it by inserting
\newenvironment{doxygen}{... most of doxygen.sty goes here ...}{}