0

I have this LaTeX document:

\section{header}

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.

\begin{Shaded}
\begin{Highlighting}[]

\KeywordTok{library}\NormalTok{(ggplot2)}
\KeywordTok{ggplot}\NormalTok{(mtcars, }\KeywordTok{aes}\NormalTok{(wt, hp)) +}\StringTok{ }\KeywordTok{geom_point}\NormalTok{()}
\end{Highlighting}
\end{Shaded}

\begin{figure}[H][htbp]
\centering
\includegraphics{figure/model.png}
\caption{plot of chunk model}
\end{figure}

This produces this PDF:

output

There are 4 things that need fixing with PDF:

  1. Get rid of [] above figure;
  2. Get rid of [H][htbp] below figure;
  3. Centre figure;
  4. Show figure caption.

I've tried various combinations of LaTeX code without success. Doe anyone have solutions to above 4 tasks?

1
  • 1
    Which \documentclass are you using? Can you make your example complete? (I.e. include a minimal preamble and a document environment so that we can copy-paste the entire thing and compile it directly.) Nov 14, 2013 at 7:13

1 Answer 1

3

Meaningless part commented for clarity:

\documentclass{article}

\usepackage{here}
\usepackage{graphicx}

\begin{document}

\section{header}

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.

%\begin{Shaded}
%\begin{Highlighting}[]

%\KeywordTok{library}\NormalTok{(ggplot2)}
%\KeywordTok{ggplot}\NormalTok{(mtcars, }\KeywordTok{aes}\NormalTok{(wt, hp)) +}\StringTok{ }\KeywordTok{geom_point}\NormalTok{()}
%\end{Highlighting}
%\end{Shaded}

%\begin{figure}[H][htbp]
\begin{figure}[H]
\centering
%\includegraphics{figure/model.png}
\includegraphics[width=0.8\textwidth]{it} % PS
\caption{plot of chunk model}
\end{figure}
\end{document}

enter image description here

Explanation:

  1. [H] suggests that you want to use the package here, forcing the position of your picture. Then [htbp] is garbage. How we can see, your wishes 1, 2, and 3 are accomplished. Well, the first [] was from the commented Highligting.

  2. Probably your image is too big. An optional parameter of \includegraphics scales here the picture to 0.8 of \textwidth. The value is to be chosen, of course. This should solve your 4th problem.

1
  • 2
    And do consider not using [H] as it leaves unnecessary gaps in the output. Learn to master [htbp] instead.
    – daleif
    Nov 14, 2013 at 8:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .