Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Linux 列印檔案實戰:pr 指令排版美化與 nroff/troff 進階排版

編輯:關於 Linux

直接列印純文字檔案往往版面凌亂。Linux 內建 pr 可快速加入頁首、分欄、邊距;若需專業排版,則可使用經典的 nroff/troff 宏套件。本文以實例示範 pr 常用參數與列印流程。

列印排版示意圖

pr 指令快速上手

pr [選項] 檔案...
常用選項:
  -k N       分 N 欄列印 (預設 1)
  -d         雙倍行距
  -h "標題"  設定頁首標題
  -t         隱藏頁首/頁尾/邊距
  -l N       每頁行數 (預設 66,文字區 56)
  -o N       左邊距空格數
  -w N       頁面寬度 (預設 72 字元)

實例:餐廳清單雙欄列印

food 檔案內容:

Sweet Tooth
Bangkok Wok
Mandalay
Afghani Cuisine
Isle of Java
Big Apple Deli
Sushi and Sashimi
Tio Pepe's Peppers
...

指令:

pr -2 -h "Restaurants" food

輸出預覽:

Nov 7 9:58 1997 Restaurants Page 1
Sweet Tooth          Isle of Java
Bangkok Wok          Big Apple Deli
Mandalay             Sushi and Sashimi
Afghani Cuisine      Tio Pepe's Peppers
.........

進階排版:nroff/troff

  • nroff:輸出至終端機/列印機,支援 -ms、-mm 宏套件。
  • troff:輸出至排版輸出裝置 (PostScript/PDF),專業出版級品質。
  • 學習曲線較陡峭,現代多改用 LaTeX、Markdown + Pandoc 流程。

pr 僅改變輸出格式,不修改原始檔案。掌握它即可快速產出整齊的列印文件。

Copyright © Windows教程網 All Rights Reserved