# Using tikz with Miktex and TexStudio

So I am using latex for submitting my homeworks, and I am struggling for hours now, just to draw some Feynman diagrams. Here is how I proceeded:

1. Install tikz-feynman from Miktex. Texstudio refuses to compile.

2. Figure out from googling I actually require TikZ (thought it must have come with the basic packages, but no). Great, put in \usepackage{tikz}. Texstudio refuses to compile.

3. Back to google - find out tikz comes with pgf, which I do not have. Went and installed pgf. Texstudio refuses to compile.

Here's my snippet:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\section{abcd}

\end{document}


Here's Texstudio's response:

Sorry, but pdflatex.exe did not succeed. The log file hopefully contains the information to get MiKTeX going again: #USER/AppData/Local/MiKTeX/2.9/miktex/log/pdflatex.log You may want to visit the MiKTeX project page, if you need help.

Process exited with error(s)


Here's the log file:

LaTeX2e <2017-04-15>
Babel <3.18> and hyphenation patterns for 75 language(s) loaded.
("D:\Software installations\MikTex\tex\latex\base\article.cls"
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
("D:\Software installations\MikTex\tex\latex\base\size10.clo"
File: size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
("D:\Software installations\MikTex\tex\latex\pgf\frontendlayer\tikz.sty"
("D:\Software installations\MikTex\tex\latex\pgf\basiclayer\pgf.sty"
("D:\Software installations\MikTex\tex\latex\pgf\utilities\pgfrcs.sty"
("D:\Software installations\MikTex\tex\generic\pgf\utilities\pgfutil-common.tex
"
\pgfutil@everybye=\toks14
\pgfutil@tempdima=\dimen103
\pgfutil@tempdimb=\dimen104

("D:\Software installations\MikTex\tex\generic\pgf\utilities\pgfutil-common-lis
ts.tex"))
("D:\Software installations\MikTex\tex\generic\pgf\utilities\pgfutil-latex.def"
\pgfutil@abb=\box26


Yes I refreshed the FNDB, updated Texstudio, changed mirrors and uninstalled and reinstalled all of the above packages a couple times now. I'm tired.

Can someone please tell me what other dependencies do I need to install in order to get pgf, tikz and subsequently tikz-feynman to work? A full code snippet would be very, very welcome at this stage, or a guide to install the required packages with a certain order, if that's the case.

• your code works well on my Windows 10 (Miktex/Texstudio)! – Black Mild Apr 11 '18 at 15:30

If MikTeX is installed correctly, using the MikTeX Console app to set the option to install missing packages automatically would go a long way to ease your stress. Console>Settings>> Select automatic download of missing packages-yes. Also download all the PGF packages, disk space is cheap. PGFPLOTS/TikZ is an awesome addition to the TeX community, but there is a multi-faceted learning curve. I took your code and ran it using the WinEdt IDE and no problems were seen. Does TeXStudio have the proper configuration? Where are you installing packages with regard to the MikTeX package structure? Permissions could come into play.

Here is a MWE that compiles fine with PDFLaTeX:

\documentclass{article}
\usepackage{tikz-feynman}
%\usetikzlibrary{positioning}

\begin{document}
\section{abcd}
\feynmandiagram [horizontal=a to b] {
i1 -- [fermion] a -- [fermion] i2,
a -- [photon] b,
f1 -- [fermion] b -- [fermion] f2,
};
\begin{tikzpicture}
\begin{feynman}
\vertex (a1) {$$\overline b$$};
\vertex[right=1cm of a1] (a2);
\vertex[right=1cm of a2] (a3);
\vertex[right=1cm of a3] (a4) {$$b$$};
\vertex[right=1cm of a4] (a5);
\vertex[right=2cm of a5] (a6) {$$u$$};

\vertex[below=2em of a1] (b1) {$$d$$};
\vertex[right=1cm of b1] (b2);
\vertex[right=1cm of b2] (b3);
\vertex[right=1cm of b3] (b4) {$$\overline d$$};
\vertex[below=2em of a6] (b5) {$$\overline d$$};

\vertex[above=of a6] (c1) {$$\overline u$$};
\vertex[above=2em of c1] (c3) {$$d$$};
\vertex at ($(c1)!0.5!(c3) - (1cm, 0)$) (c2);

\diagram* {
{[edges=fermion]
(b1) -- (b2) -- (a2) -- (a1),
(b5) -- (b4) -- (b3) -- (a3) -- (a4) -- (a5) -- (a6),
},
(a2) -- [boson, edge label=$$W$$] (a3),
(b2) -- [boson, edge label'=$$W$$] (b3),

(c1) -- [fermion, out=180, in=-45] (c2) -- [fermion, out=45, in=180] (c3),
(a5) -- [boson, bend left, edge label=$$W^{-}$$] (c2),
};

\draw [decoration={brace}, decorate] (b1.south west) -- (a1.north west)
node [pos=0.5, left] {$$B^{0}$$};
\draw [decoration={brace}, decorate] (c3.north east) -- (c1.south east)
node [pos=0.5, right] {$$\pi^{-}$$};
\draw [decoration={brace}, decorate] (a6.north east) -- (b5.south east)
node [pos=0.5, right] {$$\pi^{+}$$};
\end{feynman}
\end{tikzpicture}
\end{document}


I took your snippet and inserted some example code from the CTAN tikz-feynman docs. Some of the package examples require LUATEX or XETEX. I don't do either of these at this time, but note the tikzpicture environment will give you a lot of options. Also, the MikTex auto download feature will help in resolving packages that you have yet to install problems, but you still would have to know what you're using, ie. \usepackage{...} calls.

Best regards, Dave