-
Notifications
You must be signed in to change notification settings - Fork 0
/
groffTutorial.ms
256 lines (217 loc) · 4.26 KB
/
groffTutorial.ms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
.TL
Groff cheatsheet
.AU
Subhaditya Mukherjee
www.github.com/SubhadityaMukherjee
.NH
Introduction
.LP
Groff is a minimalistic text editor. Something like latex/markdown.
As far as I know, it exists preinstalled in most Linux distributions.
Why not use docs/markdown/latex? You could. But this is pretty easy for most things. Especially if you quickly need to create a text based PDF document with formatting and everything but you don't want to think too much.
.NH
This cheatsheet?
.LP
.I
This was also made using groff.
.LP
I will aim to go through the documentation and list down some things I find useful here. Note that this is not extensive by any means.
If you want a super extensive list just refer to
.B "man 7 groff"
on your terminal.
.NH
Setup
.RS
.IP 1.
Firstly check if groff is installed by going to the terminal and typing 'man groff'
.IP 2.
Then create a file with an extension of .ms if you dont have tables in your document. Or .me if you do.
.IP 3.
To compile the document into a PDF file we need to run the command 'groff -ms temp.ms -Tpdf > temp.pdf'.
Note that we pipe it because groff outputs to terminal otherwise.
.IP 4.
If you are using vim, you can automate this saving bit very easily.
Just go to your ~/.vimrc file and add these lines.
au BufWritePost,BufFilePost *.ms !groff -ms % -T pdf > %:r.pdf
au BufWritePost,BufFilePost *.me !tbl % | groff -me -T pdf > %:r.pdf
.IP 5.
How to write them in the file?
.IP
Add them like this:
.TL
This is the title
.LP
Hello world
.IP 6.
You can then open the .pdf with whatever you use. (I use zathura).
.RE
.NH
Basics
.NH 2
Title
.LP
This will create a title. Like this document
.TL
.NH 2
Move to left/right/center
.LP
l, r, c for left right center
.ad r
.NH 2
Author
.LP
This will add an author.
.AU
.NH 2
Indented Paragraph
.LP
This create an indent with a number . at the start. Like this list.
.IP 1.
.NH 2
Headers
.LP
This creates the next heading and autonumbers it. The number after it determines level. eg. 1 for something like 1.0, 2.0 and 2 for something like 1.1, 2.1 etc
.NH 1
.NH 2
Indented List
.LP
If you have a list you want to indent.
.RS
.IP 1.
.IP 2.
.RE
.NH 2
Convert to bold.
.LP
If you want to convert to
.B
bold.
.LP
.B
hello
.NH 2
Convert to
.I
italic.
.LP
If you want to convert to italic.
.I
hello
.NH 2
Add
.UL "underline".
.LP
If you want to add underlines.
.UL "Underlined"
.NH 2
Comments
.LP
This adds a comment to a line
\\" comment
.NH 2
Boxes
.LP
.BX "Add box around text."
.B1
.B1
hello
.B2
.B2
.NH 2
Page break
.LP
This creates a page break.
\.bp
.NH 2
Add images
.LP
Adds images. (Note: only accepts .eps files. So convert it using imageMagick. Eg: convert temp.jpg temp.eps)
.PSPIC -L "house.eps"
.PSPIC -L "house.eps"
.LP
To make things go faster you can use this command in your vimrc
groff -e -ms % -Tps > %:r.ps && ps2pdf %:r.ps %:r.pdf
.NH 2
Table of contents!
.LP
.XS 1
heading
.XA 2
heading 2
.XE
.TC
.bp
----------------------------------------------------------------
.NH
Equations
.EQ
y = 3x + 1000
.EN
.LP
This adds any kind of equations.
.EQ
y = 3x + 1000
.EN
.LP
.NH 2
Add super/subscript
.EQ
y = 3 sup{ phi +100}
.EN
This adds superscripts/subscripts. To write greek write the name of the letter.
.EQ
y = 3 sup{ phi + 100} "\\or sub for subscript
.EN
.LP
.NH 2
To add a division type thing.
.EQ
y = {1 + sqrt 5} over {2+x}
.EN
.EQ
y = {1 + sqrt 5} over {2+x}
.EN
.NH 2
To add sum over.
.EQ
y = sqrt {
{sum from i=1 to N (x sub i - x bar ) sup 2}
over
x-1
}
.EN
.EQ
y = sqrt {
{sum from i=1 to N (x sub i - x bar ) sup 2}
over {x-1}
.EN
.NH 2
To add integral
.EQ
pi = int from -1 to 1 dx over sqrt {1-x sup 2}
.EN
.EQ
pi = int from -1 to 1 dx over sqrt {1-x sup 2}
.EN
.NH 2
To add text replacement shortcuts.
.EQ
define disc `b sup 2 -4ac`
2* disc
.EN
.EQ
3* disc
.EN
.NH 2
Inline equations
.EQ
delim $$
.EN
.PP
This is a text where I can add $3 alpha + 10 beta = 4p$
.LP
.EQ
delim $$
.EN
.PP
This $3 alpha + 10 beta = 4p$