LaTeX 的通用 make 文件:需要 GNU make

LaTeX 的通用 make 文件:需要 GNU make

我在外部文件 (fig1.tex 和 fig2.tex) 中有两个 tikz 图片:

图1.tex

\documentclass[a4paper,class=minimal,border=0pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{plotmarks}
\usetikzlibrary{arrows,shapes}
\usetikzlibrary{plothandlers}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}


\begin{document}

\resizebox{18cm}{!}{ 
\begin{tikzpicture}
% \draw[help lines] (-3,-3) grid (10,10);  %%%% help grids line
%  axis
  \draw[rotate=90][->] (-1,0) -- (4,0)node[left] {\Large$\phi$} ;
  \draw[->] (-2,0) -- (7,0) node[above] {\Large$\lambda$};
  \draw(0,0) rectangle (5,2.5); 

%  node point
    \filldraw[color=blue] (0,0) circle (0.1);
    \node [below right]  at (0,0) {\large$E(0,0)$} ;
    \filldraw[color=blue] (5,0) circle (0.1);
    \node [below right]  at (5,0) {\large$E(0,1)$} ;
    \filldraw[color=blue] (0,2.5) circle (0.1);
    \node [below right]  at (0,2.5) {\large$E(1,0)$} ;
    \filldraw[color=blue] (5,2.5) circle (0.1);
    \node [below right]  at (5,2.5) {\large$E(1,1)$} ;

% p and q point
\draw[loosely dashed] (0,1.3) -- (2.1,1.3)  ;
\node [left]  at (0,1.3) {\Large$p$} ;
\draw[loosely dashed]  (2.1,0) -- (2.1,1.3) ;
\node [below] at (2.1,0) {\Large$q$};

% IPP point
\filldraw[color=red] (2,1.2) rectangle (2.2,1.4) ;
\node [right]  at (2.1,1.3) {\large$E(p,q)$} ;



\end{tikzpicture} } % end resizebox
\end{document} 
  • 图2.tex

例子:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{through}
\usetikzlibrary{calc}


\begin{document}
\begin{tikzpicture}
% Works
\coordinate (A) at (1,2);
\coordinate (B) at (2,2);
% Works
\node [draw] at (2,2) [circle through={(B)}] {};
\node [draw] at (3,5) [circle through={(B)}] {};
\node [draw] at (A) [circle through={(2,2)}] {};

\end{tikzpicture}
\end{document}

现在我正尝试将它们包括到我的主文本文件:

  • 主文本

xxxxx

\documentclass[11pt,DIV10,a4paper, titlepage,parskip=half,headings=normal,listof=totoc,bibliography=totoc,final]{scrreprt}
\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{external}
\usepackage{standalone}
\begin{document}
% Works
\begin{figure}[ht]
\centering
\includestandalone{try}
\caption{Geometry of ionospheric pirce point}\label{fig:figure2}
\end{figure}

\begin{figure}[ht]
\centering
\includestandalone{bivariate_interpolation}
\caption{Geometry of ionospheric pirce point}\label{fig:figure2}
\end{figure}

\end{document}

我正在使用Makefile文件来编译它们:

  • Makefile

LaTeX 的通用 make 文件:需要 GNU make

TEXFILE = _main.tex

.PHONY: dvi ps pdf clean

pdf:    $(TEXFILE:.tex=.pdf)
ps: $(TEXFILE:.tex=.ps)
dvi:    $(TEXFILE:.tex=.dvi)

%.dvi: %.tex
    ( \
    latex $<; \
    latex $<; \
    latex $<; \
    bibtex $(TEXFILE:.tex=.aux); \
    bibtex $(TEXFILE:.tex=.aux); \
    bibtex $(TEXFILE:.tex=.aux); \
    makeglossaries $(TEXFILE:.tex=.acn); \
    latex $<; \
    latex $<; \
    latex $<; \
    )
%.ps: %.dvi
    dvips -q $< -o $(<:.dvi=.ps)

%.pdf: %.ps
    ps2pdf -dPDFSETTINGS=/prepress $<

    @rm -f \
    $(TEXFILE:.tex=.aux) \
    $(TEXFILE:.tex=.log) \
    $(TEXFILE:.tex=.idx) \
    $(TEXFILE:.tex=.lof) \
    $(TEXFILE:.tex=.lot) \
    $(TEXFILE:.tex=.nlo) \
    $(TEXFILE:.tex=.out) \
    $(TEXFILE:.tex=.dvi) \
    $(TEXFILE:.tex=.ps) \
    $(TEXFILE:.tex=.nav) \
    $(TEXFILE:.tex=.toc) \
    $(TEXFILE:.tex=.snm) \
    $(TEXFILE:.tex=.bbl) \
    $(TEXFILE:.tex=.blg) \
    $(TEXFILE:.tex=.ilg) \
    $(TEXFILE:.tex=.ind) \
    *~ 

一切正常图1.tex,但是当我尝试编译它时图2.tex我有一个错误:

! Package pgfkeys Error: I do not know the key '/tikz/circle through'

但当我尝试编译我的图2.tex直接从控制台使用注释:

pdflatex -synctex=1 -interaction=nonstopmode "fig2".tex 

有用 !

我不知道我做错了什么。我正在使用 pgfv2.10 (opensuse) 有人能帮我吗?问候

答案1

standalone删除独立文件的前言。因此,through编译第二个图形时,tikz 库将不可用。为了避免这种情况,您必须将所有包和库(在子文件中使用的)包含在主 tex 文件的前言中。将\usetikzlibrary{through}前言放入主 tex 文件中是可行的。

\documentclass[11pt,DIV10,a4paper, titlepage,parskip=half,headings=normal,listof=totoc,bibliography=totoc,final]{scrreprt}
%\usepackage{pgf}   % this is not needed 
\usepackage{tikz}
%% following lines need to be here also. ------------
\usetikzlibrary{external}
\usetikzlibrary{through}
\usetikzlibrary{plotmarks}
\usetikzlibrary{arrows,shapes}
\usetikzlibrary{plothandlers}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
%%--------------------------------------------------
\usepackage{standalone}
\usepackage{filecontents}
\begin{filecontents*}{fig1.tex}
\documentclass[a4paper,class=minimal,border=0pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{plotmarks}
\usetikzlibrary{arrows,shapes}
\usetikzlibrary{plothandlers}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\begin{document}

\resizebox{18cm}{!}{
\begin{tikzpicture}
% \draw[help lines] (-3,-3) grid (10,10);  %%%% help grids line
%  axis
  \draw[rotate=90][->] (-1,0) -- (4,0)node[left] {\Large$\phi$} ;
  \draw[->] (-2,0) -- (7,0) node[above] {\Large$\lambda$};
  \draw(0,0) rectangle (5,2.5);

%  node point
    \filldraw[color=blue] (0,0) circle (0.1);
    \node [below right]  at (0,0) {\large$E(0,0)$} ;
    \filldraw[color=blue] (5,0) circle (0.1);
    \node [below right]  at (5,0) {\large$E(0,1)$} ;
    \filldraw[color=blue] (0,2.5) circle (0.1);
    \node [below right]  at (0,2.5) {\large$E(1,0)$} ;
    \filldraw[color=blue] (5,2.5) circle (0.1);
    \node [below right]  at (5,2.5) {\large$E(1,1)$} ;

% p and q point
\draw[loosely dashed] (0,1.3) -- (2.1,1.3)  ;
\node [left]  at (0,1.3) {\Large$p$} ;
\draw[loosely dashed]  (2.1,0) -- (2.1,1.3) ;
\node [below] at (2.1,0) {\Large$q$};

% IPP point
\filldraw[color=red] (2,1.2) rectangle (2.2,1.4) ;
\node [right]  at (2.1,1.3) {\large$E(p,q)$} ;
\end{tikzpicture} } % end resizebox
\end{document}
\end{filecontents*}
%
\begin{filecontents*}{fig2.tex}
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{through}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
% Works
\coordinate (A) at (1,2);
\coordinate (B) at (2,2);
% Works
\node [draw] at (2,2) [circle through={(B)}] {};
\node [draw] at (3,5) [circle through={(B)}] {};
\node [draw] at (A) [circle through={(2,2)}] {};

\end{tikzpicture}
\end{document}
\end{filecontents*}
\begin{document}
% Works
\begin{figure}[ht]
\centering
\includestandalone{fig1}
\caption{Geometry of ionospheric pirce point}\label{fig:figure2}
\end{figure}

\begin{figure}[ht]
\centering
\includestandalone{fig2}
\caption{Geometry of ionospheric pirce point}\label{fig:figure2}
\end{figure}

\end{document} 

相关内容