What's GNU
As you are hopefully beginning to see, troff provides you all the mechanisms you need for complete control over your document's format. Unfortunately, this is often more control than you need. Writing documents using bare troff, while possible, can be quite painful. It is very much like programming in assembly language: you have complete control, and when the result works it works really well, but there is an awful lot of detail to keep track of, and it can be tedious and difficult.
To make it easier for regular users to manage the detail, troff allows you to define macros. A macro is like a subroutine in a programming language. You can group commands together to perform a larger task, and use the macro name, instead of writing out the entire sequence of commands each time.
Consider starting a new paragraph. You have to do the following tasks:
1. See if there is room left on the page for at least two lines of text.
2. Skip a space after the last paragraph.
3. Indent the first line of text by 1/2 an inch.
You could write the commands to do this over and over again. But that is (a) tedious, (b) a hassle to update if you change how you do paragraphing. Instead, you can define a macro, say .P, to do this for you.
.de P \" DEfine paragraph macro
.ne 3 \" we NEed at least three lines
.sp \" SPace down one line
.ti .5i \" Temporary Indent .5 inches
.. \" end the macro definition
Then, in your text, you just put .P on a line by itself wherever you want a paragraph.
.ds LX the Linux Operating System
.ds LJ \fILinux Journal\fP
If you are new to \*(LX, then you should subscribe to
\*(LJ. It covers \*(LX in great detail,
month after month.
.P
And even if you are an experienced user of \*(LX,
\*(LJ will bring you valuable tips and tricks to keep
your Linux system up and running.
One of the less attractive features of standard troff is that command, macro, string, and register names are limited to no more than two characters. Fortunately, groff allows longer names, with a different syntax for accessing them. In fact, groff has many nice extensions over troff, making the task of writing macro packages considerably easier. The extensions are documented in the gtroff(1) man page.
There are a number of popular troff macro packages. Using them is like programming in FORTRAN; it beats the heck out of Assembly Language, but it's not as nice as C or Modula-3.
The common macro packages are:
-ms - Manuscript macros. Originated in V7, popular on Berkeley Unix.
-man - Manual Page macros.
-mm - Memorandum Macros. Very powerful macros, popular on System V.
-me - Berkeley Technical Paper macros. An ugly package.
-mdoc - The new Document Macros from Berkeley.
-mandoc - A package that figures out dynamically if you want -man or -mdoc.
groff will support these directly if you have them, particularly using the -C compatibility mode option. It also has its own version of many of these packages.
The -ms and -mm are the most portable packages to use. -mm has many more features than -ms, thus making it harder to learn. In the long run though, the effort is worth it, because you can do so much.
Over the years, it was found that macros helped, but that there were some things that were just too difficult to do in bare troff, even with macro packages. The approach that was developed was to write a “little language” that solved a particular task, and to pre-process the language into raw troff. The common pre-processors are:
tbl - formats tables
eqn - formats equations
pic - formats pictures (diagrams)
grap - formats graphs
As an example, here is part of a table from a reference card I worked on:
.TS
tab(~);
lfB l lfB l.
abs~absolute value~int~integer part
acos~arc cosine~log~natural logarithm
asin~arc sine~sin~sine
atan~arc tangent~sinh~hyperbolic sine
cos~cosine~sqrt~square root
cosh~hyperbolic cosine~tan~tangent
.TE
We'll explain it line by line. First, tbl only looks at lines between .TS (table start) and .TE (table end). Everything else is left alone. This makes it easy to use tbl in a pipeline with the other preprocessors. The first line sets the tab character to ~. Normally, tabs in the input separate each column of the table. For this table, a ~ is used to make it easier to mark off the columns.
Then, for each line of data in the table, you provide a line that describes the layout information. l means left justified, r means right justified, and c means centered. All the columns in this table are left justified. The first and third columns also use a different font (the f). Here, they are using the bold font.
In this example, there is only one control line, so it is applied to all the data lines. For more complicated tables, you have one control line per data line, with the last control line applying to any remaining data lines.
The other preprocessors are similar in functionality. grap is actually a preprocessor for pic.
Typically, the commands are used in a pipeline:
grap doc.tr pic tbl eqn troff -mm -Tps > doc.ps
The actual usage will vary from machine to machine; we'll see below how to run groff.
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- RSS Feeds
- New Products
- Using Salt Stack and Vagrant for Drupal Development
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- Validate an E-Mail Address with PHP, the Right Way
- New Products
- Readers' Choice Awards
Enter to Win an Adafruit Prototyping Pi Plate Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Prototyping Pi Plate Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.




4 hours 18 min ago
10 hours 18 min ago
10 hours 41 min ago
10 hours 51 min ago
10 hours 55 min ago
11 hours 25 min ago
14 hours 16 min ago
14 hours 52 min ago
14 hours 53 min ago
14 hours 54 min ago