I have a markdown file with numerous images that displays great in visual studio code.
I created the markdown file in R by scraping a section of our agencies legacy website.
The last step is to convert this md to pdf for archiving. I am doing this step in R
rmarkdown::pandoc_convert(here::here("myfile.md"),output="myfile.pdf")
The process completes, everything looks good except that the images are not centered and the figure captions do not display under the image (they wrap).
The code i am using for the images in markdown is
![label](figures/fig1.png) Figure 1 Time series of stuff
If i use html to center the image in markdown then the conversion to pdf doesn't display properly. If i enclose the figure with
\begin{figure} or \begin{center}
\end{figure} or \end{center}
then the conversion fails with an error.
Any advice. Spent too much time already reading articles not applicable
Related
I want to fit my image in the Overleaf but the output result is not as expected.
The overleaf code i used is as:
\begin{figure}[htb]
\includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{Fig2.png}
\label{Fig1}
\end{figure}
\begin{figure}[htb]
\includegraphics[scale=0.5]{Fig_3.png}
\label{Fig2}
\end{figure}
However my image is coming on top of the text of the other sections, any solutions are appreciated.
Note: The Image needs the whole page width to be accommodated
Try \pagebreak before and/or after images.
The next option is to replace [htb] with [!h].
I have a series of markdown files that I am turning into slides using Pandoc and the Beamer template. I am creating my own custom Beamer template in order to format those slides.
pandoc --slide-level 2 -fmarkdown-implicit_figures -t beamer --template mytemplate.beamer -o test.pdf *.md
I am struggling with making certain elements look the way I would like them to.
My simplified markdown looks like this:
## Header
Normal Body Text
![Image](images/Image1.png "Image")
Specifically, my images are coming out left justified. I can't figure out how to get them to center. If I remove the -fmarkdown-implicit_figures option, then the images are properly centered, but includes captions that I don't want. Adding that flag eliminates the captions but also eliminates the centering.
At the same time, I want the normal body text to be centered as well. So in the above example I would like the text Normal Body Text to be centered. Again, I can't figure out how to do that. I have managed to center other elements (such as the header), but I can't find an appropriate name for the element that represents normal body text.
Can anyone offer a solution to either of these issues?
I found a way to center the images. It may not be the best option, but this seems to work:
\usepackage{letltxmacro}
% Save the meaning of \includegraphics
\LetLtxMacro\latexincludegraphics\includegraphics
% Update the include graphics command to include centering
\renewcommand{\includegraphics}[2][]{%
\centering
\latexincludegraphics[#1]{#2}}
To ensure the normal text was centered, I used the following, again I am unsure if this is the best way:
% Center Text By Default
\usepackage{ragged2e}
\centering
I have cells underneath figures in an ipython notebook that contain figure caption text. I would like them to be centre('center')-aligned. I use "< center >" in the markdown, which gives exactly the appearance I'm after in the notebook. But when nb-converting to latex, the text gets shunted over to the left.
So is there a way to get nbconvert to recognize text alignment in markdown cells when converting to latex?
Thanks.
You have actually asked two different questions:
is there a way to get nbconvert to recognize text alignment in markdown cells
figure caption (centering) in nbconvert
ad 1)
To convert the markdown to latex pandoc is used. Unfortunately, pandoc removes raw html from markdown if converted to latex (if also removes raw latex when converting markdown to html).
So it is not that straight forward to use html tags to format the output in both html and latex. This formatting may be achieved based cell metadata but that is not that trivial currently.
ad 2)
Nevertheless it is possible to create caption like text to work with html and latex.
Here we have to distinguish between caption for pyout or stream data (e.g. Ipython.display.Image) and markdown images.
pyout and stream
A possible approach is to create a Caption class like
class Caption():
def __init__(self,s):
self.s = s
def _repr_html_(self):
return '<center>{0}</center>'.format(self.s)
def _repr_latex_(self):
return '\\begin{center}\n'+self.s+'\n\\end{center}'
which is called after the image. Note that both should be called with the IPython.display.display method, e.g as oneliner
display(Image('image.jpg'),Caption('Figure Caption'))
This approach allows process the captiontext with python, e.g. to add figure numbers.
If you want to add such a caption to a matplotlib plot, it is a bit more tricky as the wrong ordering has to be overcome. A possible approach is to plot using this snippet
%matplotlib inline
plt.plot([1,2])
f=plt.gcf()
plt.close()
display(f,Caption('Plot'))
It may be noted the the default latex template of IPython 1.x doesn't play well with this approach, as here, image and caption are only loosely coupled and thus, vertical space might be included during latex compiling. The latex_basic template works much better. In IPython master the default templates are working fine.
markdown images
Markdown allows to use images like
![Caption](/files/image)
When converting to latex pandoc can take the Caption part and create a real latex caption.
Similar, when converting to html the caption gets embedded in a caption class to be easily styleable using css.
However, currently IPython requires a "/files/" prefix which is currently not removed, thus the image file won't be found by latex. (Fixed by now)
Be aware that these markdown image calls do not embed but only link the image into the ipynb file, therefore, the image has to remain available.
Is there a way to copy text with InlineFormula styles to the clipboard with the math section within the dollar signs?
Take this for example. The following screenshot shows part of a mathematica notebook:
I have duplicated the same cell to show the expression form. Now, when I right click on the text and click copy as LaTeX and paste it say here:
\text{I hope this inline text is copied within the dollar signs: }
f(x) = 3. \text{Did} \text{it} \text{work}?
I get that. If I were to save the file as latex I would obtain something like this:
I hope this inline text is copied within the dollar signs: \(f(x) = 3\). Did it work?
I have never used \( \) in latex. But I'm assuming this is another form of doing inline math since it worked when I compiled it with LaTeX
Sometimes I find myself typing some text in Mathematica and later pasting some text with inline text into some latex file. Is there some settings I can change so that I can obtain the inline math mode instead of the \text{} command?
Another related question is, Is it possible to do display math in Latex? The DisplayFormula style doesn't seem to work quite right.
Any knowledge about latex settings in Mathematica is welcome.
I want to insert a .jpg image(that is in my current folder, where the .tex file is) after a paragraph. How can I do it in Latex? What should I include / what commands should I use?
You need to use a graphics library. Put this in your preamble:
\usepackage{graphicx}
You can then add images like this:
\begin{figure}[ht!]
\centering
\includegraphics[width=90mm]{fixed_dome1.jpg}
\caption{A simple caption \label{overflow}}
\end{figure}
This is the basic template I use in my documents. The position and size should be tweaked for your needs. Refer to the guide below for more information on what parameters to use in \figure and \includegraphics. You can then refer to the image in your text using the label you gave in the figure:
And here we see figure \ref{overflow}.
Read this guide here for a more detailed instruction:
http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions
if you add a jpg,png,pdf picture, you should use pdflatex to compile it.