LaTeX to normal text: remove the command and keep the text
Want to turn LaTeX source code into readable ordinary text? This article explains how to remove backslash commands, environment tags, and introductory areas, retain text paragraphs, and explain how to deal with formulas, tables, and references.
Key points of this article
- First distinguish the main text, introductory area and commands in the source code, and then keep only the main text part.
- When removing formatting commands, keep the text in curly brackets, for example, \textbf{emphasis}, leaving only "emphasis".
- Formulas, tables and references should be handled separately, and deleting them directly will usually lose key information.
- After finishing, read through paragraph by paragraph and check numbers, proper nouns and references against the compiled PDF.
Many people get a LaTeX source file (.tex) and want to copy the paper paragraphs or report content into emails, web pages, or ordinary documents, but find that the screen is full of marks like \section, \cite{}, and \begin{equation}. Copied directly, the reading experience is very poor. This type of requirement is different from "convert PDF to Word": the source file itself is text, and what needs to be done is to strip off the formatting commands, leaving only the text that readers need.
This article is for writers, students, and teaching assistants who need to extract text from .tex source code. After reading, you can judge what content should be kept and what should be deleted, organize the source code into clean plain text in a fixed order, and know what to check after finishing. If you search for "online LaTeX to normal text", the method here is also applicable to reviewing the output results of online tools.
How to convert LaTeX source code to ordinary text? One sentence conclusion
First delete the introductory area and environment tags, then replace the formatting commands with curly brackets with the text in the curly brackets, process the formulas and tables separately, and finally read through the compilation results. This order allows changes to be made from large to small, making it easier to locate errors.
| your situation | Recommended practices | reason |
|---|---|---|
| Just paragraph text, no formulas or tables | Delete the introductory area, remove common commands, and retain the text in curly brackets | Small processing volume and low error probability |
| Contains a large number of inline formulas | Change the formula to "[formula]" placeholder, or keep the original writing and list it separately | Converting formulas to plain text is prone to distortion |
| Contains tables | Rewrite each line as "column name: value", or align with tabs | Table structure cannot be retained in ordinary text |
| Includes references and cross-references | Keep the author’s year or number and check it item by item. | After deleting the citation tag, readers cannot trace the source. |
| The file is very long and there are many commands | First use search and replace to process repeated commands, and then read through them manually. | Manually deleting items one by one is time-consuming and easy to miss |
Before you start: Confirm these points first
Taking a few minutes to make judgment before taking action can avoid reworking the entire document.
- Do you want the text, or the source code that can be recompiled? If it is only for reading or quoting text, it can be converted into plain text; if it needs to be compiled later, just delete it on the copy and keep the original file unchanged.
- Are there multiple .tex files? Chapters are often written in separate files and introduced through \input or \include. These chapter files must also be processed together, otherwise the text will be missing chapters.
- Are there any custom commands? If there is a macro defined by \newcommand or \def in the preamble area, the macro name appears in the text. Before deleting the introductory area, you must first write down the text after these macro expansions, otherwise the content will disappear directly.
- Is it a Chinese document? Chinese source code often uses ctex or xeCJK to set the font in the introduction area. These settings can be deleted in entirety, but the file encoding must be unified to UTF-8, otherwise the converted Chinese will be easily garbled.
- Are there any backups? All deletions made from copy. Once deleted by mistake, the original files can still be retrieved.
Steps to organize LaTeX text in the editor
The following steps apply to any software that can edit plain text. If you want to continue typesetting, you can put the organized content into the UniDoc web editor (app.unidoc.top) for editing. The editor supports LaTeX round-trip conversion and Markdown format.
- Copy a copy of the source file. The original file remains unchanged, all modifications are done on the copy.
- Delete the introductory area. Delete the content between \documentclass and \begin{document}, but first note down the macro definitions for replacement later.
- Delete the first and last marks of the document. Remove \begin{document}, \end{document} and \maketitle tags that are only responsible for typesetting.
- Change the chapter title to a normal title line. Change \section{Introduction} to "Introduction" or the second-level title of Markdown, and \subsection will be downgraded in the same way.
- Remove the formatting command and keep the text. Remove the commands and curly brackets in \textbf{emphasis}, \emph{emphasis}, and \textit{italic}, leaving only the text in the brackets.
- Process formulas, tables and picture marks. In-line formulas can be kept as they are or replaced with "[formula]" placeholders; tables can be changed to "column names: values" row by row; image commands such as \includegraphics can be deleted directly, leaving a legend in the original position.
- Handle references and cross-references. Replace \cite{smith2020} with the author year such as "(Smith, 2020)", or retain the number; delete \ref and \label in pairs, and change statements such as "As shown in Figure 1" to directly describe the content.
- Save as UTF-8 plain text. Check the encoding, save it, and read it through again to make sure that the blank lines between paragraphs are not lost.
Check each item after completion
Just because the organization is complete doesn’t mean there are no problems. The following items are prone to errors and it is recommended to check them one by one.
| Check items | How to see | What to do if there is a problem |
|---|---|---|
| residual backslash | Search for "\" to see the remaining positions | Confirm one by one whether it is a command, if so, delete or rewrite it. |
| Are the curly braces paired? | Count the number of left and right curly braces | If it is not paired, it means that the content was deleted by mistake. Please go back to the copy to retrieve it. |
| Numbers and proper nouns | Paragraph-by-paragraph comparison with compiled PDF | Any differences will be corrected in PDF. |
| Formula meaning | Check whether there is a placeholder or original formula in the formula position | Important formulas are restored to their original writing |
| Reference correspondence | Check whether each citation can be found in the references | If missing, fill in the author's year or number. |
| Chinese display | Open it with an editor and see if a box or question mark appears. | Confirm that the file is UTF-8 and then save it again |
📊 Core comparison
There are three common plain text extraction methods, each of which is suitable for different scenarios.
| method | Suitable | Main risks |
|---|---|---|
| Manually delete paragraph by paragraph | A short document with few commands | Time consuming, easy to miss deep commands |
| Find and replace plus manual read-through | Documents that are long and have repeated commands | If the replacement rule is written too wide, it will accidentally damage the backslashes or curly braces in the text. |
| Copy from compiled PDF | Only the rough text is required, not the format. | Headers and footers, page numbers, line breaks and hyphens are mixed in, and formulas are often garbled. |
For most people, first using search and replace to process repeated commands, and then manually correcting formulas and tables is a better balance between efficiency and accuracy.
❓ Frequently Asked Questions (FAQ)
1. Is it possible to directly copy the compiled PDF text?
You can get the text quickly, but the result will have headers and footers, page numbers and line breaks, and hyphens will be left in the middle of words. Formulas often don't copy correctly and need to be sorted out again.
2. Do you want to keep the formula?
If the reader needs to understand the formula itself, keep the original writing, or use words to describe its meaning. If it is just to be read aloud, summarized or put into a normal document, just use "[formula]" as a placeholder and explain it elsewhere.
3. Can online website conversion be completed in one step?
Online conversion websites can handle simple commands and paragraphs, but content can easily be missed when encountering custom macros and special environments. When selecting, you can see file size limits, whether your content will be retained or uploaded, and whether the output will retain paragraph structure. It is recommended to treat its output as a first draft and check it against the checklist in this article.
4. What to do with references after deleting \cite?
Change citations to author year or number, and place the reference list separately at the end of the article. This way the text can still be traced to its source and reading will not be interrupted by marks.
5. The Chinese source code is garbled when converted, how to deal with it?
First make sure the file is saved in UTF-8 encoding, and then check whether Chinese support packages such as ctex or xeCJK are set in the introductory area. Garbled characters are mostly caused by inconsistent encoding, which can usually be solved by re-saving after unified encoding.
📝 Summary
The key to turning LaTeX source code into ordinary text is to first distinguish the structure, text and formulas, then remove the commands in order and retain the content in the curly brackets. After finishing, be sure to compare it with the compiled PDF to check numbers, references, and proper nouns.


