我正在寻找用于(输入)和/或 MSH 文件格式版本 2 或 4 (gmsh 输出)的语法高亮包(aslistings
或minted
) 。*.geo
gmsh
*.msh
*.geo
文件内容示例
// Scale global grid element size
Mesh.CharacteristicLengthFactor = 1.5;
// Corners of the domain
Point(0) = { 0, 0, 0};
Point(1) = { 1, 0, 0};
Point(2) = { 1, 0.5, 0};
Point(3) = {0.5, 0.5, 0};
Point(4) = {0.5, 1, 0};
Point(5) = { 0, 1, 0};
// Boundary edges of the domain
Line(1) = {0,1};
Line(2) = {1,2};
Line(3) = {2,3};
Line(4) = {3,4};
Line(5) = {4,5};
Line(6) = {5,0};
// Boundary of the domain
Line Loop(1) = {1,2,3,4,5,6};
// The domain itself
Plane Surface(1) = {1};
*.msh
文件内容示例
$MeshFormat
2.2 0 8
$EndMeshFormat
$Nodes
41
1 0 0 0
2 1 0 0
3 1 0.5 0
4 0.5 0.5 0
5 0.5 1 0
6 0 1 0
7 0.1999999999995576 0 0
8 0.3999999999989744 0 0
9 0.5999999999989459 0 0
10 0.799999999999472 0 0
11 1 0.1666666666662511 0
12 1 0.3333333333328939 0
13 0.8333333333333334 0.5 0
14 0.6666666666666664 0.5 0
15 0.5 0.6666666666666666 0
16 0.5 0.8333333333333336 0
17 0.3333333333337959 1 0
18 0.1666666666673608 1 0
19 0 0.7999999999999998 0
20 0 0.6000000000013879 0
21 0 0.4000000000016655 0
22 0 0.2000000000008337 0
23 0.3004167819879116 0.1698674110639992 0
24 0.3573897665780844 0.7519396544085315 0
25 0.7493717760200707 0.3546064511829626 0
26 0.1686224557471811 0.50405397113411 0
27 0.1779609363946547 0.71146970615191 0
28 0.495504820869713 0.1721077777534667 0
29 0.3924239084393696 0.3257134258816227 0
30 0.7105370841400358 0.1697025991610465 0
31 0.1879455962969176 0.3132686117470094 0
32 0.3352865041851164 0.5968275518324213 0
33 0.5857507093559758 0.3370217089965164 0
34 0.8651451872920622 0.2403492373476806 0
35 0.2547071208804222 0.8694417796334968 0
36 0.3077458663907779 0.4468353126333099 0
37 0.1464101615131833 0.1464101615135252 0
38 0.3788401225744933 0.8788401225743672 0
39 0.8779915320719285 0.3779915320718109 0
40 0.1198669447884875 0.8761822971570814 0
41 0.875136454286314 0.1153437006349956 0
$EndNodes
$Elements
86
1 15 2 0 0 1
2 15 2 0 1 2
3 15 2 0 2 3
4 15 2 0 3 4
5 15 2 0 4 5
6 15 2 0 5 6
7 1 2 0 1 1 7
8 1 2 0 1 7 8
9 1 2 0 1 8 9
10 1 2 0 1 9 10
11 1 2 0 1 10 2
12 1 2 0 2 2 11
13 1 2 0 2 11 12
14 1 2 0 2 12 3
15 1 2 0 3 3 13
16 1 2 0 3 13 14
17 1 2 0 3 14 4
18 1 2 0 4 4 15
19 1 2 0 4 15 16
20 1 2 0 4 16 5
21 1 2 0 5 5 17
22 1 2 0 5 17 18
23 1 2 0 5 18 6
24 1 2 0 6 6 19
25 1 2 0 6 19 20
26 1 2 0 6 20 21
27 1 2 0 6 21 22
28 1 2 0 6 22 1
29 2 2 0 1 23 29 31
30 2 2 0 1 27 26 32
31 2 2 0 1 28 30 33
32 2 2 0 1 31 29 36
33 2 2 0 1 34 30 41
34 2 2 0 1 24 27 32
35 2 2 0 1 30 25 33
36 2 2 0 1 29 28 33
37 2 2 0 1 4 29 33
38 2 2 0 1 30 10 41
39 2 2 0 1 29 4 36
40 2 2 0 1 23 28 29
41 2 2 0 1 11 12 34
42 2 2 0 1 23 8 28
43 2 2 0 1 20 21 26
44 2 2 0 1 20 26 27
45 2 2 0 1 7 8 23
46 2 2 0 1 27 24 35
47 2 2 0 1 28 9 30
48 2 2 0 1 9 10 30
49 2 2 0 1 8 9 28
50 2 2 0 1 19 20 27
51 2 2 0 1 4 32 36
52 2 2 0 1 26 21 31
53 2 2 0 1 21 22 31
54 2 2 0 1 15 16 24
55 2 2 0 1 4 15 32
56 2 2 0 1 13 14 25
57 2 2 0 1 14 4 33
58 2 2 0 1 25 30 34
59 2 2 0 1 34 12 39
60 2 2 0 1 27 35 40
61 2 2 0 1 15 24 32
62 2 2 0 1 25 14 33
63 2 2 0 1 26 31 36
64 2 2 0 1 1 7 37
65 2 2 0 1 22 1 37
66 2 2 0 1 10 2 41
67 2 2 0 1 6 19 40
68 2 2 0 1 32 26 36
69 2 2 0 1 17 18 35
70 2 2 0 1 12 3 39
71 2 2 0 1 3 13 39
72 2 2 0 1 16 5 38
73 2 2 0 1 5 17 38
74 2 2 0 1 19 27 40
75 2 2 0 1 18 6 40
76 2 2 0 1 31 22 37
77 2 2 0 1 7 23 37
78 2 2 0 1 23 31 37
79 2 2 0 1 25 34 39
80 2 2 0 1 24 16 38
81 2 2 0 1 13 25 39
82 2 2 0 1 11 34 41
83 2 2 0 1 2 11 41
84 2 2 0 1 17 35 38
85 2 2 0 1 35 18 40
86 2 2 0 1 35 24 38
$EndElements
答案1
这是一个lstlisting
例子,其中的定义取自 Nektar++ - Project 的用户指南(参见https://github.com/certik/nektar)。当然,您也可以直接引用*.geo
- 和*.msh
-文件,而无需先将代码复制到文件中.tex
。这会使整个事情变得更清晰一些。
\documentclass{article}
\usepackage{xcolor}
\usepackage{listings} % Display code / shell commands
\usepackage{lstautogobble}
%\newcommand{\shellcommand}[1]{\begin{lstlisting} \#1 \end{lstlisting}
\lstdefinestyle{BashInputStyle}{
language=bash,
basicstyle=\small\ttfamily,
% numbers=left,
% numberstyle=\tiny,
% numbersep=3pt,
frame=single,
columns=fullflexible,
backgroundcolor=\color{yellow!10},
linewidth=\linewidth,
xleftmargin=0.05\linewidth,
keepspaces=true,
framesep=5pt,
rulecolor=\color{black!30},
aboveskip=10pt,
autogobble=true
}
\definecolor{gray}{rgb}{0.4,0.4,0.4}
\definecolor{darkblue}{rgb}{0.0,0.0,0.6}
\definecolor{cyan}{rgb}{0.0,0.6,0.6}
\definecolor{maroon}{rgb}{0.5,0.0,0.0}
\definecolor{darkgreen}{rgb}{0.0,0.5,0.0}
\lstdefinelanguage{XML}
{
basicstyle=\ttfamily\footnotesize,
morestring=[b]",
moredelim=[s][\bfseries\color{maroon}]{<}{\ },
moredelim=[s][\bfseries\color{maroon}]{</}{>},
moredelim=[l][\bfseries\color{maroon}]{/>},
moredelim=[l][\bfseries\color{maroon}]{>},
morecomment=[s]{<?}{?>},
morecomment=[s]{<!--}{-->},
commentstyle=\color{gray},
stringstyle=\color{orange},
identifierstyle=\color{darkblue},
showstringspaces=false
}
\lstdefinestyle{XMLStyle}{
language=XML,
basicstyle=\ttfamily\footnotesize,
numbers=left,
numberstyle=\tiny,
numbersep=3pt,
frame=,
columns=fullflexible,
backgroundcolor=\color{black!05},
linewidth=\linewidth,
xleftmargin=0.05\linewidth,
keepspaces=true
}
\lstset{%
escapeinside={(*}{*)},%
}
\begin{document}
\begin{lstlisting}[style=BashInputStyle]
$MeshFormat
2.2 0 8
$EndMeshFormat
$Nodes
41
1 0 0 0
2 1 0 0
3 1 0.5 0
4 0.5 0.5 0
5 0.5 1 0
6 0 1 0
7 0.1999999999995576 0 0
8 0.3999999999989744 0 0
9 0.5999999999989459 0 0
10 0.799999999999472 0 0
11 1 0.1666666666662511 0
12 1 0.3333333333328939 0
13 0.8333333333333334 0.5 0
14 0.6666666666666664 0.5 0
15 0.5 0.6666666666666666 0
16 0.5 0.8333333333333336 0
17 0.3333333333337959 1 0
18 0.1666666666673608 1 0
19 0 0.7999999999999998 0
20 0 0.6000000000013879 0
21 0 0.4000000000016655 0
22 0 0.2000000000008337 0
23 0.3004167819879116 0.1698674110639992 0
24 0.3573897665780844 0.7519396544085315 0
25 0.7493717760200707 0.3546064511829626 0
26 0.1686224557471811 0.50405397113411 0
27 0.1779609363946547 0.71146970615191 0
28 0.495504820869713 0.1721077777534667 0
29 0.3924239084393696 0.3257134258816227 0
30 0.7105370841400358 0.1697025991610465 0
31 0.1879455962969176 0.3132686117470094 0
32 0.3352865041851164 0.5968275518324213 0
33 0.5857507093559758 0.3370217089965164 0
34 0.8651451872920622 0.2403492373476806 0
35 0.2547071208804222 0.8694417796334968 0
36 0.3077458663907779 0.4468353126333099 0
37 0.1464101615131833 0.1464101615135252 0
38 0.3788401225744933 0.8788401225743672 0
39 0.8779915320719285 0.3779915320718109 0
40 0.1198669447884875 0.8761822971570814 0
41 0.875136454286314 0.1153437006349956 0
$EndNodes
$Elements
86
1 15 2 0 0 1
2 15 2 0 1 2
3 15 2 0 2 3
4 15 2 0 3 4
5 15 2 0 4 5
6 15 2 0 5 6
7 1 2 0 1 1 7
8 1 2 0 1 7 8
9 1 2 0 1 8 9
10 1 2 0 1 9 10
11 1 2 0 1 10 2
12 1 2 0 2 2 11
13 1 2 0 2 11 12
14 1 2 0 2 12 3
15 1 2 0 3 3 13
16 1 2 0 3 13 14
17 1 2 0 3 14 4
18 1 2 0 4 4 15
19 1 2 0 4 15 16
20 1 2 0 4 16 5
21 1 2 0 5 5 17
22 1 2 0 5 17 18
23 1 2 0 5 18 6
24 1 2 0 6 6 19
25 1 2 0 6 19 20
26 1 2 0 6 20 21
27 1 2 0 6 21 22
28 1 2 0 6 22 1
29 2 2 0 1 23 29 31
30 2 2 0 1 27 26 32
31 2 2 0 1 28 30 33
32 2 2 0 1 31 29 36
33 2 2 0 1 34 30 41
34 2 2 0 1 24 27 32
35 2 2 0 1 30 25 33
36 2 2 0 1 29 28 33
37 2 2 0 1 4 29 33
38 2 2 0 1 30 10 41
39 2 2 0 1 29 4 36
40 2 2 0 1 23 28 29
41 2 2 0 1 11 12 34
42 2 2 0 1 23 8 28
43 2 2 0 1 20 21 26
44 2 2 0 1 20 26 27
45 2 2 0 1 7 8 23
46 2 2 0 1 27 24 35
47 2 2 0 1 28 9 30
48 2 2 0 1 9 10 30
49 2 2 0 1 8 9 28
50 2 2 0 1 19 20 27
51 2 2 0 1 4 32 36
52 2 2 0 1 26 21 31
53 2 2 0 1 21 22 31
54 2 2 0 1 15 16 24
55 2 2 0 1 4 15 32
56 2 2 0 1 13 14 25
57 2 2 0 1 14 4 33
58 2 2 0 1 25 30 34
59 2 2 0 1 34 12 39
60 2 2 0 1 27 35 40
61 2 2 0 1 15 24 32
62 2 2 0 1 25 14 33
63 2 2 0 1 26 31 36
64 2 2 0 1 1 7 37
65 2 2 0 1 22 1 37
66 2 2 0 1 10 2 41
67 2 2 0 1 6 19 40
68 2 2 0 1 32 26 36
69 2 2 0 1 17 18 35
70 2 2 0 1 12 3 39
71 2 2 0 1 3 13 39
72 2 2 0 1 16 5 38
73 2 2 0 1 5 17 38
74 2 2 0 1 19 27 40
75 2 2 0 1 18 6 40
76 2 2 0 1 31 22 37
77 2 2 0 1 7 23 37
78 2 2 0 1 23 31 37
79 2 2 0 1 25 34 39
80 2 2 0 1 24 16 38
81 2 2 0 1 13 25 39
82 2 2 0 1 11 34 41
83 2 2 0 1 2 11 41
84 2 2 0 1 17 35 38
85 2 2 0 1 35 18 40
86 2 2 0 1 35 24 38
$EndElements
\end{lstlisting}
\begin{lstlisting}[style=XmlStyle]
// Scale global grid element size
Mesh.CharacteristicLengthFactor = 1.5;
// Corners of the domain
Point(0) = { 0, 0, 0};
Point(1) = { 1, 0, 0};
Point(2) = { 1, 0.5, 0};
Point(3) = {0.5, 0.5, 0};
Point(4) = {0.5, 1, 0};
Point(5) = { 0, 1, 0};
// Boundary edges of the domain
Line(1) = {0,1};
Line(2) = {1,2};
Line(3) = {2,3};
Line(4) = {3,4};
Line(5) = {4,5};
Line(6) = {5,0};
// Boundary of the domain
Line Loop(1) = {1,2,3,4,5,6};
// The domain itself
Plane Surface(1) = {1};
\end{lstlisting}
\end{document}