我在教程的帮助下创建了一个简单的图表。如果我只使用教程中提到的软件包,图表本身就可以工作并编译,而且编译得很完美,但是当我将图表添加到我的 latex 文件中时,它却无法编译。我知道这与软件包有关...有人能帮我添加/修改正确的软件包吗?
我知道它可以工作。其他代码也可以单独工作。我需要的是第二个文件中的图形。正如我所说,其他文件也可以工作。
也许我没有按照预期编写代码。请注意,我已删除并创建了一个简单的文件,以便您可以帮助我。它不是最终版本,也不是代码本身。只是我想要做的核心。这两个文件都可以独立工作,我请求的是帮助将两者合并到一个可编译的文件中。–
这是图形文件
\documentclass{article}
\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows,automata}
\usepackage[latin1]{inputenc}
\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=2pt,auto,node distance=2.8cm,
semithick]
\tikzstyle{every state}=[fill=gray,draw=none,text=white]
\node[state] (A) {$1$};
\node[state] (B) [above right of=A] {$2$};
\node[state] (C) [right of=B ] {$3$};
\path
(A) edge node {} (B)
edge node {} (C)
(B) edge node {} (C)
(C) edge node {} (A);
\end{tikzpicture}
\end{document}
当我想将图形添加到正在创建的需要其他包的 Latex 文件中时,出现了问题:
\documentclass{article}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish,activeacute]{babel}
\usepackage{amsmath, amssymb}
\usepackage{graphicx}
\graphicspath{ {F:\Espacio de trabajo/} }
\title{Problema}
\author{MNLR}
\begin{document}
\maketitle
\chapter{\textit{\begin{flushleft}\normalsize{ Things I have to do... }\end{flushleft}}}
\chapter{\begin{flushleft}\normalsize{ blah blah }\end{flushleft}}
\chapter{\begin{flushleft}\normalsize{
\begin{itemize}
\item It's times like this ...
\item \textbf{that make me say }
\end{itemize}
}\end{flushleft}}
\end{document}
我确实知道一切都正常。我只需要将两者合并到一个文件中。也就是说,将图表放入另一个代码中。
谢谢。
答案1
这是将两个文档合并在一起的代码的清理版本。它依赖于 Gonzalo Medina 解释的解决方案这里这需要 PGF/TiKZ 版本 3.0。如果您使用的是旧版本,则需要使用该答案中也解释的解决方法或(最好)更新。
\documentclass[spanish]{book}% article has no chapters; pass language as class option so all language-sensitive packages know about it
\usepackage[activeacute]{babel}
\usepackage[utf8]{inputenc}% make sure everything uses the same encoding - save your files in the encoding you are using
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath, amssymb}
\usepackage{tikz}
\usetikzlibrary{arrows,automata,babel}% use the babel library to avoid problems due to the spanish localization: see https://tex.stackexchange.com/a/166775/ for details and for an alternative workaround for pre-3.0 versions of TiKZ/PGF
\title{Problema}
\author{MNLR}
\begin{document}
\maketitle
\chapter{Things I have to do\dots}% get rid of the markup in the arguments as formatting in the arguments here is just wrong and will definitely break stuff
\begin{tikzpicture}
[
->,
>=stealth',
shorten >=2pt,
auto,
node distance=2.8cm,
semithick,
every state/.style={fill=gray, draw=none, text=white},
]
\node[state] (A) {$1$};
\node[state] (B) [above right of=A] {$2$};
\node[state] (C) [right of=B ] {$3$};
\path
(A) edge node {} (B)
edge node {} (C)
(B) edge node {} (C)
(C) edge node {} (A);
\end{tikzpicture}
\chapter{blah blah}
\chapter{It's times like this \dots that make me say}
\end{document}