Hot answers tagged

13

I run/schedule 'canned' PDF reports using *roff, generating tables and simple PICs as I process the data with python, and organizing sources with simple bash scripts. Smooth & Simple. Like vi, *roff is always there, ready-to-run and generates clean PDFs with minimal fuss. I like *roff's terse markup. This said, I don't pretend to be a representative ...


10

I am using troff for my everyday typesetting; I am using the Heirloom version of troff (see http://heirloom.sourceforge.net/doctools.html ) which has very powerful support for fonts (TTF, Type1, OTF, etc.), Knuth's algorithm for formatting the paragraph as well as several micro-typesetting features that you can't find in plain TeX; it is lighter than LaTeX ...


9

I've heard that troff/groff have largely been replaced by TeX. Is this true? The only thing that I know actually used troff nowadays is manpages. Is this also true? I've only ever seen troff/groff being used for manpages; for everything else, people seem to use TeX or LaTeX. So I'd answer yes and yes. If not, what are some other uses? Apparently ...


7

The "first form" is a... feature of groff. If your "nroff" is not a wrapper for groff, you will see only the second form. The feature is referred to in the manual page for grotty (groff driver for typewriter-like devices): By default, grotty emits SGR escape sequences (from ISO 6429, also called ANSI color escapes) to change text attributes (bold,...


5

You might peek at how the fish shell builds its completions from the man pages in particular how __fish_complete_man works. An easier option assuming groff might be to emit HTML and then use one of the multitude of HTML parsers out there to get what you want: $ groff -T html -mdoc xpquery.1 | xpquery -p HTML '//p[b="xpquery"][2]' - <p style="margin-left:...


5

groff -man -Tascii < /path/to/manpage/without/gz | less EG: groff -man -Tascii < C:/Programs/msysgit/mingw/man/man1/gcc.1 | less Note: Although switching shells is not needed here, mysysgit uses sh (not bash) as the default shell. Thanks to devnull for pointing thatr out.


5

You could use the open source software Calibre (http://calibre-ebook.com). It is available for OSX, Windows, and Linux. Input Formats: CBZ, CBR, CBC, CHM, DJVU, EPUB, FB2, HTML, HTMLZ, LIT, LRF, MOBI, ODT, PDF, PRC, PDB, PML, RB, RTF, SNB, TCR, TXT, TXTZ Output Formats: AZW3, EPUB, FB2, OEB, LIT, LRF, MOBI, HTMLZ, PDB, PML, RB, PDF, RTF, SNB, ...


4

That's more the reverse of what groff is designed to do. What you're looking for can be achieved at least with this combination of tools: aha wkhtmltopdf pdf2ps from ghostscript Like: printf '\e[31;1mfoo\e[mbar\n' | aha | wkhtmltopdf - - | pdf2ps - output.ps A bit overkill but it does the trick. You can probably skip the last part as PDF is as ...


4

The .RE restores the default indentation level, not the current .TP indentation level. All you need to do is save and restore the actual indent in play when .RS is called. The fix below assumes you will not nest SAMPLEs inside SAMPLEs: .de SAMPLE .br .nr saveIN \\n(.i \" double the backslash when defining a macro .RS .nf .nh .. .de ESAMPLE .hy .fi .RE ....


4

In the original file, the minus '-' symbols really are backslashified to '\-' which would then be interpreted in the way you do not like. A solution is to filter the file before feeding it to man for formatting: zcat /usr/share/man/man1/ls.1.gz | man -tl - > ls-normal.ps zcat /usr/share/man/man1/ls.1.gz | sed 's/\\-/-/g' | man -tl - > ls-minus.ps ...


4

The ms macros have displays which are sets of lines with no fill, so each input line is one output line, and which can all be indented by some amount, or be right justified. This indents by 12cm: .DS I 12c John Doe Somewhere Else .DE and this aligns the right end of the text: .DS R John Doe Somewhere Else .DE There are also base troff commands to indent ...


3

Groff supports a CW (constant width) font, and you can select it with .ft CW or \f(CW. To turn off filling, use a display, .DS - .DE, or a .nf - .fi pair. .TL Two boxes, two ways .LP ASCII drawing .DS C .ft CW +-------------------------+ +-----------------+ | | | | | Hello ...


3

There are a number of 2-character macros that let you format their arguments in two different fonts, alternating between them. In your case, you'd use the .IR macro. R means Roman, the default font. The default is .IR /etc/audit/audit.key .


3

For an ASCII version groff -Tascii -mm PROMO.mm For a postcript version groff -Tps -mm PROMO.mm


3

You can look through man groff_mm, or the actual macro definition file (/usr/share/groff/*/tmac/m.tmac) to see that the mm macros are by far the larger, and more complete of the three original troff packages. However, they have all been overtaken by the gnu mom macro package developed specially for groff and postscript/pdf output. If you are interested in ...


3

Your man command is using groff to format the page with ANSI color escape sequences (ISO 6429), and your pagination program (likely more or less) is expanding these unprintable characters instead of passing them unchanged to your terminal screen. To tell less (for example) not to expand these ANSI sequences, use the -R or --RAW-CONTROL-CHARS option. You ...


2

PostScript is a programming language for placing marks on paper. To make said marks colored, you have to include the correct instructions in the program. They take a very different form from the crude ANSI escape codes VT100 clones understand. I don't remember much of troff (and when I wrote my thesis with it, color printers weren't even a dream...), but in ...


2

I applaud your use of old school text processing. But I'm a bit of a dinosaur. groff has a command line flag "-m" so for the "ms" macros, you'd do this: groff -m ms .... That said, I don't recall a lot of functional difference between mm and me. I kept my resume in groff until very recently, and apparently, I found the "ms" macro package to be entirely ...


2

From mdoc(7) The special meaning of a punctuation character may be escaped with the string ‘\&’ So: \&. However this might be tricky in combination with subsequent lines as things like \&. \&.as s "nron, nroff--very good, again! Run together (and produces a whole bunch of blank lines) $ nroff blah | head -2 . .as s "nron, nroff‐‐very ...


2

The POSIX Programmer's Manual has its own dedicated sections in man, namely 0p (header files), 1p (commands) and 3p (functions). You can restrict your search to those sections: [haxiel@testvm1 ~]$ man -k -s 0p,1p,3p mmap mmap (3p) - map pages of memory If you want to search the full text, replace the -k option (apropos) with the -K option (...


2

Character A0 is an unbreakable space. It looks like it is between "Jakieś" and "informacje". Use your editor to replace it by a normal space and you should be good to go. Advice: I've set up my editors (emacs, vim) to highlight unbreakable spaces because I sometimes unintentionally type some with AltGr+space when I hit space after typing a character ...


2

Man pages are roff formatted text files, which unfortunately is one of the most irritating to parse formatting languages around right now. You may have some luck pulling out what you want by looking through the documentation for whatever roff implementation your system uses (it will almost always be one of nroff, troff, or groff). The format itself is ...


2

The date is set in the source code for the man page -bash-4.2$ man -w man /usr/share/man/man1/man.1.gz -bash-4.2$ zcat $(man -w man) | fgrep 2012 .TH MAN 1 "2012-09-17" "2.6.3" "Manual pager utils" -bash-4.2$ Not portably, as OpenBSD for example instead places the date in .Dd $ man -w man /usr/share/man/man1/man.1 /usr/share/man/man7/man.7 $ grep 2017 $(...


2

The following convoluted way works: groff -Kutf8 -Tdvi -mec -ms test.ms > test.dvi dvipdfm -cz 9 test.dvi open test.pdf Via the [Groff] latin2 polish special characters thread on lists.gnu.org.


2

Assuming you have looked at .NH 2 to give you 2nd level numbered headings, and that is not what is wanted, you can use your own number register, as shown in the man page .IP indented paragraph example. Add to the start the definition and initialisation of your number register (starts at 0, increment by 1) .nr mytheorem 0 1 then whereever you use it as \...


2

Yes, groff can perform arithmetic. This is documented in the full groff manual, which is available online or in GNU Info format (use info groff, or pinfo groff to see the full manual)....as with many GNU programs, the man page is just a quick reference, full docs are in Info format. From https://www.gnu.org/software/groff/manual/html_node/Expressions.html ...


2

The current page number is \n% . To interpolate the result of an arithmetic expression, I think you'll need to put it in a number register first. Here's a macro (not exhaustively tested) that takes an expression as its argument, assigns the result to a (presumably unused) register named __, then interpolates the contents of the register. Current page is \...


2

A document typeset with the mom macros needs to have a bit more setup than just defining the title. In particular, it needs .START. Defining the title of the document won't make it appear in the document. This is a fairly minimal mom document: .TITLE "Stretched to the Breaking Point" .PRINTSTYLE TYPESET .PAPER A4 .START See e.g. the ...


2

If you want to use the FAM string to specify a font family you will need to use conventional names with the suffixes R B I BI for roman, bold, italic, and bold-italic. In the linked-to example, the font family was DejaVuSans, so you need to provide fonts DejaVuSansR, DejaVuSansB, DejaVuSansI, and DejaVuSansBI. The following worked for me: mkdir -p /tmp/font/...


Only top voted, non community-wiki answers of a minimum length are eligible