Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using pandoc to convert markdown to pdf, but I need to place some figures with more formating than the

  ![Alt text](image.png)

so I use something like this:

  # Document with figures

  This document have figures but they appear before the title

  \begin{figure}
  \centering
  {\includegraphics[width=2.5in]{some_figure.png}}
  \caption{Comparing Dq from different p-model}
  \end{figure}

and then I use the following command:

 pandoc -H test_fig.sty test_fig.md -o test_fig.pdf

and test_fig.sty have:

 \usepackage{graphicx}

the resulting pdf have first the figure and then the title.

share|improve this question

migrated from stackoverflow.com Mar 10 at 1:37

1 Answer

up vote 1 down vote accepted

This is most likely because the figure environment floats, which is not what you're after. For this you have a couple of options:

  1. Add the float package which provides the H float specifier, allowing you to use

    \usepackage{float}% http://ctan.org/pkg/float
    %...
    
    \begin{figure}[H]
    %...
    \caption[<ToC>]{<regular>}
    \end{figure}
    

    stopping the float from moving around.

  2. Add the caption (or the super-tiny capt-of) package and wrap your figure inside a minipage to keep the image and caption together. Use it as follows:

    \usepackage{caption}% http://ctan.org/pkg/caption
    %\usepackage{capt-of}% http://ctan.org/pkg/capt-of
    %...
    
    \noindent\begin{minipage}{\textwidth}
    %...
    \captionof{figure}[<ToC>]{<regular>}
    \end{minipage}
    %...
    

For more information on the placement of figures, see How to influence the position of float environments like figure and table in LaTeX? and Keeping tables/figures close to where they are mentioned.

The above proposal are purely LaTeX-driven.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.