How to use the command 'eqn' (with examples)
The ’eqn’ command is an equation preprocessor that is used in conjunction with the groff (GNU Troff) document formatting system. It is commonly used to process input with equations and save the output for future typesetting with groff to PostScript or other formats like PDF.
Use case 1: Process input with equations, saving the output for future typesetting with groff to PostScript
Code:
eqn path/to/input.eqn > path/to/output.roff
Motivation:
This use case is useful when you have an input file with equations that you want to preprocess and save the output in a format that can be further processed by groff for typesetting to PostScript. It allows you to separate the equation preprocessing step from the final typesetting step.
Explanation:
eqn
: This is the command that invokes the eqn equation preprocessor.path/to/input.eqn
: This is the path to the input file containing equations that need to be processed.>
: This is a shell redirection operator that directs the output of the command to a file instead of the standard output.path/to/output.roff
: This is the path to the output file where the processed output will be saved in groff format.
Example output:
The output of this command will be the processed output of the equations contained in the input file in groff format. This output can then be used as input to the groff command for typesetting to PostScript or other formats.
Use case 2: Typeset an input file with equations to PDF using the [me] macro package
Code:
eqn -T pdf path/to/input.eqn | groff -me -T pdf > path/to/output.pdf
Motivation:
In this use case, we want to typeset an input file with equations to a PDF format using the [me] macro package. This can be useful when you want to create professional-looking documents with complex mathematical equations.
Explanation:
eqn
: This is the command that invokes the eqn equation preprocessor.-T pdf
: This option specifies the output format as PDF.path/to/input.eqn
: This is the path to the input file containing equations that need to be typeset.|
: This is a pipe operator that directs the output of the first command to the input of the second command.groff
: This is the command that formats the document using the [me] macro package.-me
: This option specifies the [me] macro package.-T pdf
: This option specifies the output format as PDF.>
: This is a shell redirection operator that directs the output of the command to a file instead of the standard output.path/to/output.pdf
: This is the path to the output file where the typeset PDF will be saved.
Example output:
The output of this command will be a typeset PDF file containing the equations from the input file, formatted using the [me] macro package. The resulting PDF can be opened with a PDF viewer or printed as needed.
Conclusion:
The ’eqn’ command is a powerful tool for processing equations in conjunction with the groff document formatting system. It allows you to preprocess equations and save the output for future typesetting to formats like PostScript and PDF. By understanding and utilizing the different options and arguments of the ’eqn’ command, you can effectively process and typeset equations in your documents.