1. Overview

In this tutorial, we’ll discuss ways to convert LaTeX to plain text. Mainly, our tutorials will show how to use it employing a LaTeX editor.

2. LaTeX and Plain Text

LaTeX is a high-quality document generation software applicable to several academic and scientific fields. We can do many things in LaTeX, including:

  1. Create complex equation
  2. Customize page numbering
  3. Cunning on various operating systems without changing any settings
  4. Automate repetitive tasks
  5. Create custom illustration

Plain text, however, is unformatted text without any styling or special characters.

LaTeX enables us to format our document with various mathematical symbols or notations that are not available in plain text. Furthermore, it provides better control of document formatting for consistent styling, making it visually appealing and professional-looking.

Plain text is easy to read and edit. In particular, it can be manipulated with any text editor. Plain text is compatible with different operating systems and computers, making it suitable for storing data and exchanging simple messages or notes.

2.1. Benefit of Plain Text Over LaTeX

While LaTeX software generates a high-quality document with advanced features, sometimes we may need the output to be in plain text for certain reasons:

  1. Simplicity: the plain text is easy to read, write and edit, as we do not require special knowledge or software. In LaTeX, we need special knowledge on how to write in LaTeX and the use of special characters like \alpha and \beta
  2. Compatibility: plain-text documents are compatible with any computing system, irrespective of the operating systems
  3. Collaboration: plain-text documents are useful for collaboration between experts in different fields, especially when some collaborators do not know how to use LaTeX or have it installed on a laptop, the plain text becomes necessary
  4. Portability: the plain text does not contain complex equations and formatting, making its files lightweight and ideal for storage on limited storage devices
  5. Accessibility: plain-text files are fully accessible to people with visual impairments, as we can easily convert the files to other formats

3. Steps to Converting LaTeX to Plain Text

We’ll describe three ways of converting a LaTeX file (in .tex format) to plain text in .txt extension:

  1. LaTeX editor method
  2. Command line method
  3. Copy and paste method

3.1. LaTeX Editor Method

To convert a LaTeX document with a .tex extension, we can use any LaTeX editor such as TeXstudio, Texmaker, and so on. We can do this in the following steps using, for example, TeXstudio:

  1. Open the LaTeX file in TeXstudio: the first step is to launch TeXstudio and click on “File” from the menu bar, and “Open” the LaTeX file we want to convert
  2. Click on the “Save as” option, and a dialogue box will appear
  3. In the dialogue box, we’ll provide a file name and select the “plaintext files” for the file type
  4. Click “Save” to export our LaTeX document as plain text.

It is relevant to note that the plain text will remove all LaTeX formatting and special characters, such as \alpha,\ \mathfrak{L}, and \ \mathbb{R}.

3.2. Command Line Method

We need to have LaTeX installed on our computer to use the command line to convert from LaTeX to plain text. We can do that by using the detex command.

Suppose we want to convert a filed named latex_file.tex to plain_file.txt, where “plain_file” will be the name of the converted file and “.txt” is the file extension.

So, go to the command line where latex_file.tex is located and run the following command:

detex latex_file.tex > plain_file.txt

Thus, we convert the latex_file.tex to plain text and save the output as plain_file.txt.

The image next demonstrates the previously described scenario:

plain text convert

The output of the LaTeX-generated document and that of plain text is shown below:

plain text output

While the LaTeX-generated document is in three colors, the plain text is generated one color text without the mathematical terms.

3.3. Copy and Paste Method

Copy and paste method requires a plain text editor such as Notepad (for Windows) or TextEdit (on Mac).

We can do this in the following steps in TeXstudio:

  1. Open our LaTeX document in TeXstudio
  2. Select the content to convert to plain text and “copy” or “Ctrl+C”
  3. Open a plain-text editor such as Notepad
  4. Paste the selected content into the editor
  5. Save the plain text with the .txt extension

4. Limitation of Converting to Plain Text

LaTeX uses packages to execute advanced rendering features such as tikzincludegraphics, and lipsum. Moreover, we can also use LaTeX to create complex equations over multiple lines. So, when converting LaTeX files to plain text, both equations and formatting resources will be lost because special packages are required to render them.

After converting a document, we should review the plain text to ensure all changes were properly done. Thus, we may need to manually reformat it or use a specialized converter tool to retain particular formatting in our plain-text document (if required).

5. Conclusion

In this article, we describe why we need to convert LaTeX to plain text. Next, we show three methods of converting from LaTeX to plain text. Lastly, we pointed out the limitations of converting LaTeX to plain text.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.