Take the 2-minute tour ×
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 have difficulty in using standalone package along with TikZ.

I have the following standalone file: l1NormInAction.tex


\documentclass[tikz,border=3mm]{standalone}

\begin{document}

\begin{tikzpicture}
\draw [thick, ->] (-1.5,0)--(3,0);
\draw [thick, ->] (0,-1.5)--(0,2);
\draw[blue,dashed, thick] (-1,0)--(0,1)--(1,0)--(0,-1)--cycle;
\node[above right] at (0,1) {$\hat{\mathbf{x}}$};
\node[below left] at (0,0) {$\mathbf{x}$};
\draw[<->,shorten <=-1cm, shorten >=-3mm,thick] (0,1)--(2,0) node [right, above] {$\mathbf{D}$};
\end{tikzpicture}

\end{document}

_________________________________________________________________

Using standalone package I used the following code in my document.

\begin{figure}[!htb]
\centering
\includestandalone[width=.8\textwidth]{figures/l1NormInAction}
\end{figure}

The output is attached here. This is not in the expected format and it contains some strange number. Where am I going wrong?

enter image description here

share|improve this question
    
Sorry, but I can't reproduce the problem. What TeX distribution are you using? –  egreg Jul 15 at 22:33
    
My Tex version is TeX 3.1415926 (TeX Live 2013/Debian). Please see my comment for Andrew's answer. –  Sooraj Jul 15 at 22:54
add comment

1 Answer 1

For me this works fine, producing the image:

enter image description here

You didn't say what your main tex file looks like, so perhaps that's the problem? I used:

\documentclass{amsart}

\usepackage{standalone}
\usepackage{tikz}
\begin{document}

\begin{figure}[!htb]
\centering
\includestandalone[width=.8\textwidth]{f}
\end{figure}

\end{document}

(I renamed your standaline file to f.tex.)

If you are still having problems then post a full MWE.

share|improve this answer
    
Thanks for your efforts. I could also compile the minimum version you provided. But my original code is very lengthy and I may not be able to provide it here. But I think, the numbers printed on the left side of the figure has some information about the error. Any clue in that direction? –  Sooraj Jul 15 at 22:52
    
@Sooraj The numbers are likely to be tikz dimensions, but they could be anything. As your "code is lengthy" I suggest that you try selectively commenting out things until you can isolate what is causing the problem. –  Andrew Jul 16 at 8:24
add comment

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.