%EB%A5%BC%20%EA%B7%B8%EB%A6%B4%20%EC%88%98%20%EC%9E%88%EB%82%98%EC%9A%94%3F.png)
문제가 생겼습니다. 저는 석사과정 학생이고 LaTeX로 논문(그래프 이론)을 쓰고 있습니다.
그래프를 그리고 LaTeX 온라인에 코드를 삽입할 수 있는 온라인 웹사이트를 찾는 데 도움을 줄 수 있는 사람이 있나요?
답변1
다음은 R에서 igraph 패키지를 사용하고 knitr 및 pdflatex를 사용하여 결과를 pdf 파일에 포함시키는 예입니다. 운영 체제 및 설정에 따라 실제 작업 흐름 세부 사항이 다를 수 있습니다.
일반적으로 1) 내장된 R 명령을 사용하여 라텍스 파일을 만듭니다. 이를 확장명 *.Rnw(대소문자 구분)로 저장합니다. 2) 이제 R을 사용하여 이 *.Rnw 파일에 대해 knit 명령을 실행합니다. 원본 *.Rnw 파일과 동일한 기본 이름을 가진 *.tex 파일을 얻을 수 없습니다. 3) pdflatex를 실행한 후 *.pdf 파일을 봅니다.
다음은 예제 소스 파일입니다(다음에서 추출됨).http://www.r-graph-gallery.com/247-network-chart-layouts/).
\documentclass[10pt,letterpaper]{article}
\begin{document}
Demo of Graph Theory using R and Tikz
<<>>=
# library
library(igraph)
# Create data
data=matrix(sample(0:1, 400, replace=TRUE, prob=c(0.8,0.2)), nrow=20)
network=graph_from_adjacency_matrix(data , mode='undirected', diag=F )
# When ploting, we can use different layouts:
par(mfrow=c(2,2), mar=c(1,1,1,1))
plot(network, layout=layout.sphere, main="sphere")
plot(network, layout=layout.circle, main="circle")
plot(network, layout=layout.random, main="random")
plot(network, layout=layout.fruchterman.reingold, main="fruchterman.reingold")
@
\end{document}
그리고 결과는
답변2
무료로 가입하는 것을 고려해 볼 수도 있습니다.세이지매스 클라우드sagetex
LaTeX 패키지 와 함께 컴퓨터 대수학 시스템 Sage의 강력한 기능을 제공하는 계정입니다 . 선적 서류 비치여기. Sage는 그래프 이론에 대한 지식을 가지고 있습니다. 예를 들어명명된 그래프,그래프 매개변수, 그리고 심지어LaTeX 옵션. 이는 tikz
세부 사항을 관리하기 위해 Sage의 강력한 기능을 사용 하여 그래프를 만들 수 있다는 것을 의미합니다 . 예는 다음과 같습니다.
\documentclass{article}
\usepackage{sagetex}
\usepackage{tikz,tkz-graph,tkz-berge}
\thispagestyle{empty}
\begin{document}
Here's a graph where you specify the position of the vertices. Note that the label is placed inside unless specified:\\\\
\begin{center}
\begin{tikzpicture}[scale=1.5]
\renewcommand*{\VertexLineWidth}{1pt}%vertex thickness
\renewcommand*{\EdgeLineWidth}{1pt}% edge thickness
\GraphInit[vstyle=Normal]
\Vertex[Lpos=270,L=$v_1$,x=0,y=0]{R1}
\Vertex[LabelOut,Lpos=270,L=$v_2$,x=0,y=2]{R2}
\Vertex[LabelOut,Lpos=270,L=$v_3$,x=1,y=1]{R3}
\Vertex[LabelOut,Lpos=270,L=$v_4$,x=2,y=1]{R4}
\Vertex[LabelOut,Lpos=270,L=$v_5$,x=3,y=1]{R5}
\Vertex[LabelOut,Lpos=270,L=$v_6$,x=4,y=1]{R6}
\Vertex[LabelOut,Lpos=90,L=$v_7$,x=3,y=2]{R7}
\Vertex[LabelOut,Lpos=90,L=$v_8$,x=4,y=2]{R8}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Edge (R3)(R4)
\Edge (R3)(R1)
\Edge (R2)(R3)
\Edge (R5)(R4)
\Edge (R5)(R6)
\Edge (R5)(R7)
\Edge (R6)(R8)
\Edge (R7)(R8)
\end{tikzpicture}
\end{center}
But \textsf{Sage} has knowledge of graph theory and you can use it to specify graphs
and determine various characteristics. For example:\\\\
\begin{sagesilent}
H= graphs.PetersenGraph()
H.set_latex_options(scale=3.5,graphic_size=(2.1,2.1))
Chi = H.chromatic_number(algorithm="DLX")
Beta = H.independent_set()
\end{sagesilent}
\noindent The Petersen graph below has $\sage{H.order()}$ vertices and
$\sage{H.size()}$ edges.\\\\
\begin{center}
\begin{tikzpicture}
\GraphInit[vstyle=Normal]
\SetVertexNormal[Shape=circle,LineWidth = 1pt]
\tikzset{EdgeStyle/.append style = {color = blue!60, line width=1pt}}
\sage{H}
\end{tikzpicture}
\end{center}
\vspace{5pt}
The chromatic number is $\chi(G)=\sage{Chi}$. The maximum size independent
set is $\beta(G)=\sage{len(Beta)}$. One such set is $\sage{Beta}$. The
maximum size clique has $\omega(G)=\sage{H.clique_number()}$ vertices;
e.g., $\sage{H.clique_maximum()}$. The diameter is $\sage{H.diameter()}$
and the radius is $\sage{H.radius()}$.
\end{document}
Sagemath Cloud에서 실행되는 결과는 다음과 같습니다.
그림을 확대하면 Sage가 그래프의 매개변수를 계산한 것을 볼 수 있습니다. 이는 중요한 문서에서 실수를 방지하는 좋은 방법입니다.
답변3
Geogebra에서 그린 모든 것을 tikz 코드로 내보낼 수 있습니다. 이 튜토리얼을 참조하세요.https://www.sharelatex.com/blog/2013/08/28/tikz-series-pt2.html