i am compiling some eps graphs with gnuplot using the following terminal line:
set terminal postscript enhanced eps color dashed rounded dl 4 "Times-Roman" 24
An example:
p 'file1' u 5:6 w p t 't=0.5 ms',\
'file2' u 5:6 w p t ' 1 ms',\
'file3' u 5:6 w p t ' 2 ms'
I added extra spaces in the key to have a nice alignment for the labels in the key. This alignment works fine if i open the resulting eps with ghostviewer, but if i compile it within a latex file
$ latex
... pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2015/dev/Debian) ...
then the text in the key is misaligned. It happens especially if i am using special typesetting like subscripts or superscripts:
p 'file1' u 5:6 w p t 't_{something}=0.5 ms'
then the text will be totally jeopardized, like overlapping text or weird alignments, but only after compiling within latex.
Have you ever seen this before?
Many thanks
edit: add a minimal example
gnuplot script:
set terminal postscript enhanced eps color dashed rounded dl 4 "Times-Roman" 24
set key spacing 1.1 samplen 1.2 top left
set output 'out.eps'
p 3*x w p lc 1 t 't=0.5 ms',\
2*x w p lc 2 t ' 1 ms'
everything fine if I run:
$gv out.eps
i compile the following latex file:
\documentclass[final,5p,times,onecolumn]{elsarticle}
\usepackage{float}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{fixltx2e}
\usepackage{epstopdf}
\journal{Combustion and Flame}
\begin{document}
\begin{figure*}[]
\centering\includegraphics[width=\textwidth]{out}
\caption{caption.}
\end{figure*}
\end{document}
using the following script ($name=latex file name):
latex $name.tex
latex $name.tex
dvips $name.dvi
ps2pdf $name.ps
using acroread, evince or xpdf, the 't=0.5 ms' label overlaps the corresponding key symbol, while visualizing out.eps on gv shows everything fine, with key text aligned to the right.
FURTHER EDIT:
replacing elsarticle with book solves the problem!
LAST EDIT:
compiling with pdflatex instead of latex solves the problem
Related
I'm having issues turning this word equation into a LaTex equation. It's coming out looking dodgy, please help!
I added a screen shot of the equation I want, and what I end up getting when I copy and paste into LaTex:
WORD:
LATEX CODE:
\mathrm{=\ }\mathrm{C}_\mathrm{0}\mathrm{[1-}6(Dt)1/2aπ2-3Dta2] + 12(Dt)1/2an = 1∞exp(na(Dt)1/2)
and therefore nothing comes out and LaTex doesn't let me run it.
This is absolutely not a proper LaTeX equation code. I don't know what you know about LaTeX, but you cannot just copy and paste from Word or any software to you LaTex editor. Plus, you need to provide your full code for anyone being able to help you.
Anyway, running this MWE should work :
\documentclass[11pt, a4paper, twoside]{report}
% ===== PACKAGES DECLARATION =====
\usepackage{mathtools} % Replaces amsmaths + more features
\usepackage{amsfonts} % Maths fonts package
% ===== DOCUMENT BODY =====
\begin{document}
\begin{equation} % optional : use the "equation*" environment to remove equation number
% optional : use traditional math font by removing the \mathrm{} command
\mathrm{X = C_0 \left[ 1 - \frac{6(Dt)^{1/2}}{a \pi^2} - \frac{3Dt}{a^2}\right] + \frac{12(Dt)^{1/2}}{a} \sum_{n=1}^\infty \exp\left(\frac{na}{(Dt)^{1/2}} \right)}
% optional : remove auto-sized brackets by removing the \left and \right commands
\end{equation}
\end{document}
As written in the code, you may want to remove the equation number and the big auto-sized brackets (that are more readable in my opinion). Just remove the corresponding commands. Also, you should consider using the "normal" math font and not the roman one that is clearly different from the text and helps the reader to separate equations from inline small expressions you could insert in your document.
One first sketch:
\documentclass{article}
\begin{document}
\[
C_0\left[1-\frac{6(Dt)^{\frac{1}{2}}}{a\pi^2}-\frac{3Dt}{a^2}\right]+%
\frac{12(Dt)^{\frac{1}{2}}}{a}\sum^{\infty}_{n=1}%
\exp\left(\frac{na}{(Dt)^{\frac{1}{2}}}\right)
\]
\end{document}
No packages required. The output:
Than you can tune the math fonts and anything else.
I am trying to convert Latex scripts to restructured text (rST) via Pandoc.
This works well, except for labelled equations.
Is there some configuration/filter for Pandoc which can correctly format equation labels?
For example, the source Latex
\section{Test section}
Some test equation
\begin{equation}
\label{test_eqn}
a = 100
\end{equation}
And then we reference \ref{test_eqn}.
yields
Test section
============
Some test equation
.. math::
\label{test_eqn}
a = 100
And then we reference `[test_eqn]`_.
.. _[test_eqn]: #test_eqn
but the desired output is
Test section
============
Some test equation
.. math::
:label: test_eqn
a = 100
And then we reference :eq:`test_eqn`.
This might be an edge case, but I'm trying to create a beamer presentation with knitr where I want to display a code chunk using different formulas as arguments for a function. I found that when using overlays, the tilde in the code chunks disappear. Is there a way to get them to display?
Here's a minimal reproducible example:
\documentclass{beamer}
\begin{document}
\begin{frame}[fragile]
\frametitle{Slide with overlay}
\only<1>{
<<notilde, eval = FALSE>>=
myfunction(data, formula = ~ x)
#
}
\only<2>{
<<notilde2, eval = FALSE>>=
myfunction(data, formula = y ~ x)
#
}
\end{frame}
\begin{frame}[fragile]
\frametitle{Slide without overlay}
<<tilde, eval = FALSE>>=
myfunction(data, formula = ~ x)
#
\end{frame}
\end{document}
The first frame of the presentation looks like this:
Any help is appreciated.
EDIT:
The slide without overlay looks like this:
To clarify, the syntax of <<...>> and # is specific to the R package knitr. Anything between these symbols are interpreted by knitr as R code chunks and converted to latex to include syntax highlighting.
You can replace the ~ with the math mode $\sim$
If not in a special environment like verbatim, the tilde in latex is a protected space, i.e. a space at which no line break occurs.
It is not clear from your question: is it working for your second frame, without overlay?
I don't know part of your syntax: is the << ... >>= ... # equivalent to a verbatim or code environmet? It looks a bit, as your text is set in a fixed space font and has syntax highlihting.
I would like to have code and an image side-by-side in a Beamer slide.
In LaTeX I would do this with columns. I would like to use markdown within the column structure.
\begin{columns}
\column{.5\textwidth}
~~~~~~~~Python
>>> some python code
~~~~~~~
\column{.5\textwidth}
![](A_generated_image.pdf)
\end{columns}
Unfortunately Pandoc doesn't process the markdown within the \begin{columns} and \end{columns} statements. Is there a way around this?
Is there a way to use markdown within inlined LaTeX?
Is there a pure markdown solution?
Current versions of pandoc (i.e., pandoc 2.0 and later) supports fenced divs. Specially named divs are transformed into columns when targeting a slides format:
# This slide has columns
::: columns
:::: column
left
::::
:::: column
right
::::
:::
Pandoc translates this into the following LaTeX beamer code:
\begin{frame}{This slide has columns}
\protect\hypertarget{this-slide-has-columns}{}
\begin{columns}[T]
\begin{column}{0.48\textwidth}
left
\end{column}
\begin{column}{0.48\textwidth}
right
\end{column}
\end{columns}
\end{frame}
This is simple and has the additional advantage of giving similar results when targeting other presentational formats like reveal.js.
More than two columns work out of the box for Beamer output. Powerpoint, however, only supports two columns. For reveal.js, the widths of three or more columns must be given explicitly:
::: columns
:::: {.column width=30%}
left
::::
:::: {.column width=30%}
middle
::::
:::: {.column width=30%}
right
::::
:::
The problem is that pandoc ignores markdown if it finds a \begin{}. An alternative is to edit the beamer template and add the following:
\newcommand{\columnsbegin}{\begin{columns}}
\newcommand{\columnsend}{\end{columns}}
And write it like this:
\columnsbegin
\column{.5\textwidth}
~~~~~~~~Python
>>> some python code
~~~~~~~
\column{.5\textwidth}
![](A_generated_image.pdf)
\columnsend
I hope still valuable. I made a Pandoc filter in Python to put columns easily, so you can write your presentations in this way:
# Hello World
[columns]
[column=0.5]
~~~python
if __name__ == "__main__":
print "Hello World"
~~~
[column=0.5]
This is how a "Hello World" looks like in Python
[/columns]
that the filter will convert each markup to \begin{columns} and \column{.5\textwidth}, so, the document above will turn in
\begin{frame}[fragile]{Hello}
\begin{columns}
\column{0.5\textwidth}
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{some python code}
\end{Highlighting}
\end{Shaded}
\column{0.5\textwidth}
Hello World
\end{columns}
\end{frame}
The code filter is here
import pandocfilters as pf
def latex(s):
return pf.RawBlock('latex', s)
def mk_columns(k, v, f, m):
if k == "Para":
value = pf.stringify(v)
if value.startswith('[') and value.endswith(']'):
content = value[1:-1]
if content == "columns":
return latex(r'\begin{columns}')
elif content == "/columns":
return latex(r'\end{columns}')
elif content.startswith("column="):
return latex(r'\column{%s\textwidth}' % content[7:])
if __name__ == "__main__":
pf.toJSONFilter(mk_columns)
If you never use a pandoc filter, just save the filter to the same document location as columnfilter.py (or other name you want) and run
pandoc -t beamer --filter columnfilter.py yourDocument.mkd
And enjoy!
Beamer Specific Answer. I ran across a solution when attempting to add multiple columns for Pandoc in a regular document. It works here as well, though it does constrain you to Beamer; though that is your use case.
In the slide deck, insert once:
---
header-includes:
- \newcommand{\hideFromPandoc}[1]{#1}
- \hideFromPandoc{
\let\Begin\begin
\let\End\end
}
---
Then add content thus:
\Begin{columns}
\Begin{column}{0.3\textwidth}
Res ipsum loquiter, sed in inferno decit?
\End{column}
\Begin{column}{0.3\textwidth}
Res ipsum loquiter, sed in inferno decit?
\End{column}
\Begin{column}{0.3\textwidth}
Res ipsum loquiter, sed in inferno decit?
\End{column}
\End{columns}
Creating the "hideFromPandoc" command lets you insert begin/end statements throughout without depriving you of markdown in the block.
Fenced Div Answer. There's an answer above that refers to fenced divs. I commented that the answer only works with two columns. It breaks down with more. Here is how that answer works with multiple divs:
::: {.columns}
:::: {.column width=0.3}
Test
::::
:::: {.column width=0.3}
Test
::::
:::: {.column width=0.3}
Test
::::
:::
To get this answer, I had to look at the commit that added the column feature specifically.
You could use FletcherPenney MultiMarkdown which can process markdown to LaTeX/Beamer. Compared to Pandoc, MultiMarkdown has not so many features. However, especially when working with LaTeX it has the advantage that you can embed LaTeX code directly into the Markdown in HTML comments.
Your code would look like this:
<!-- \begin{columns} -->
<!-- \column{.5\textwidth} -->
>>> some python code
<!-- \column{.5\textwidth} -->
![](A_generated_image.pdf)
<!-- \end{columns} -->
For me this solution works fine. With a good editor (e.g. Scrivener, Sublime Text) you can write the latex code without all the comments and find/replace them after editing. In addition, the Metadata support in Multimarkdown is much more flexible, so that it is easier to customize presentations.
In the meantime, I hope that the Pandoc team provides a solution to this problem. I think there are some users who would like to embed small LaTex code particles throughout their markdown documents without having them converted/escaped.
You can use MultiMarkDown comments ( "<!-- Your LaTeX Code inside -->" ) with Pandoc when you enclose the Pandoc command in which you transform your markdown to LaTeX with two sed commands.
In the first sed run, you change the MultiMarkDown comments to "\verb+AAAAAAALaTeX-StuffZZZZZZ+". Then you transform to LaTeX with Pandoc as usual, everything inside "\verb+AAAAAAALaTeX-StuffZZZZZZZ+" is left alone. Then you run sed on the TeX-File and delete the "\verb+AAAAAAA" and "ZZZZZZ+" unfolding your LaTeX code.
The first sed command line before the Pandoc transformation could look like this:
sed -E -e "s/<\\!--(.+)--\\>/\\\\verb\+AAAAAAA\1ZZZZZZZ\+/g " \
source.md > source.i.md
Then use Pandoc on source.i.md as usual to create source.tex. Second sed run like this:
sed -E -e "s/\\\\verb\+AAAAAAA(.+)ZZZZZZZ\+/\1/g" -i "" source.tex
I automated everything in a Makefile so that I can make more changes e.g. to table definitions in one step. On first glance this approach works fine (tested it on column definitions with the beamer class).
With this little sed scripts, you can use all the nice things from Pandoc. You need only to mmd-comment those TeX and LaTeX commands which become either escaped or enclose larger parts of your Markdown.
I have installed gnuplot through macports but when i compile my latex document in texshop it doesn't show the plots and I get these errors in the log file:
Package pgf Warning: Plot data file `tutorial.x.table' not found. on input line
17.
Package pgf Warning: Plot data file `tutorial.sin.table' not found. on input li
ne 19.
Package pgf Warning: Plot data file `tutorial.exp.table' not found. on input li
ne 21.
I'm just trying to compile this basic example:
% Author: Till Tantau
% Source: The PGF/TikZ manual
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
% GNUPLOT required
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}[domain=0:4]
\draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
\draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};
\draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$};
\draw[color=red] plot[id=x] function{x}
node[right] {$f(x) =x$};
\draw[color=blue] plot[id=sin] function{sin(x)}
node[right] {$f(x) = \sin x$};
\draw[color=orange] plot[id=exp] function{0.05*exp(x)}
node[right] {$f(x) = \frac{1}{20} \mathrm e^x$};
\end{tikzpicture}
\end{document}
Yes, you need to turn the .gnuplot files that tikz creates into the tables files. You have two choices for this:
you can run (pdf)latex with the additional command line switch --shell-escape, sometimes also called --enable-write-18, then gnuplot is run automatically for you. (You might not be comfortable with allowing arbitrary programs to be starte from within pdflatex, though.)
you can run gnuplot yourself on the test.exp.gnuplot, test.sin.gnuplot, test.x.gnuplot etc. files. Simply gnuplot test.exp.gnuplot should do it. (Can't verify here, since my gnuplot version is too old.)