Creating a graph in LyX

lyx
2,947

According to @scottkosty, you should be able to import the following snippet into Lyx.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\newdimen\R % radius
\R=1.5cm 
\newdimen\SmallR % node radius
\SmallR=0.5cm
\newcommand{\A}{360/7}
\begin{tikzpicture}
\node[circle,minimum size=2*\SmallR,draw,thick] (1) at (0,0) {1};
\foreach \X in {2,...,8}
{\node[circle,minimum size=2*\SmallR,draw,thick] (\X) at ({-\X*\A+180}:\R) {\X};}
\foreach \X in {2,...,8}
{\pgfmathtruncatemacro{\Y}{mod(\X-1,7)+2}
\draw[-latex] (\X)--({\Y});
\draw[-latex] (1)--({\Y});}
\end{tikzpicture}
\end{document}

When compiled with pdflatex, it produces

enter image description here

Share:
2,947

Related videos on Youtube

Admin
Author by

Admin

Updated on August 01, 2022

Comments

  • Admin
    Admin over 1 year

    I am new to LyX and I was trying to build the following graph:

    enter image description here

    • I tried to draw it using Paint but failed to do a proper graph. Hope LyX can do a better job then me.

    How To draw this graph in LyX?

    • Bernard
      Bernard almost 6 years
      Welcome to TeX SX! I'm no user of LyX, but I can explain a LaTeX code to obtain this graph.
    • Sandy G
      Sandy G almost 6 years
      Welcome to TeX.SX. Please read the introductory material for this site. When you post a question, please provide a "Minimal Working Example" (MWE) that starts with \documentclass, includes all relevant \usepackage commands, ends with \end{document} and compiles without errors, even if it does not produce your desired output.
    • scottkosty
      scottkosty almost 6 years
      LyX does not provide any tool that helps you make such diagrams. I suggest either using TikZ (like the answer by marmot), or using a program called dia. LyX has integration with dia (Insert > File > External Material), so you can right click on a dia diagram in LyX and click "edit" and it will launch dia so you can edit it.
  • scottkosty
    scottkosty almost 6 years
    +1 nice solution. Questions about LyX are encouraged at tex.se. See e.g. here: tex.stackexchange.com/help/on-topic. In fact, we even have a "LyX" tag here. And yes, you can use custom LaTeX code in LyX.
  • Admin
    Admin almost 6 years
    @scottkosty Thanks for letting me know. I was glancing through the LyX web site and from what I read there it looked as if this is possible, but I was not sure. Thanks for clarifying this.
  • scottkosty
    scottkosty almost 6 years
    Yeah it doesn't look clear on the website. What is unfortunately not possible in LyX is to seamlessly toggle between editing LaTeX and using LyX. This is why LyX is not really a "LaTeX editor"; it is a "LaTeX exporter".
  • Admin
    Admin almost 6 years
    @scottkosty Thanks again. Doesn't sound too convenient, then. And probably it won't be straightforward to include an MWE in the document.
  • scottkosty
    scottkosty almost 6 years
    The .lyx format is just a text file so it can be pasted in just like a .tex file can. The user should give a .lyx MWE and also the exported LaTeX MWE (so that non-LyX users can help). I always point LyX users to the following Wiki page: wiki.lyx.org/FAQ/MinimalExample