I opened up a file of mine in TexWorks. There were no line numbers. So, I navigated to Edit > Preferences and checked the line numbers box.


Oddly enough, if I open up a new empty document, line numbers are displayed for the new document. However, there are no line numbers in my existing document. I have tried closing TexWorks, restarting it, and reopening my document. However, anytime I open my document instead of creating a new one, line numbers fail to display.

new doc and old doc

Any thoughts?

I'm running Windows 10 Home Edition

tex works version


In menu EditPreferences☑ Lines numbers you set the default behavior for new or unkown documents, but you can change the settings only for the actually edited document in menu FormatLines numbers (see image below).

This will change the behavior of that file even if you close and open the file again, while it is in the Recent Files List, i.e., with FileOpen RecentClear Recent files you will lost that individual settings of all your files, so the next time you open the file, you will see the default behavior set in the Preferences window.



This is a behaviour "by design" see open issue at https://github.com/TeXworks/texworks/issues/222

"This is the current design. The Preferences items affect the state in which new windows are opened, but do not modify already-existing windows; for that, use the Format menu items in the window concerned.

I don't want to lose the ability to have per-window settings, as (in my experience) different options are appropriate for different kinds of file. But I can imagine perhaps being "smart" about these window options, e.g., by recording for each window whether it is using the default (in which case a Preferences change would affect it immediately) or if it has been explicitly set by the user (in which case the user's setting will "stick" even if Preferences are changed).

Along with this, we should remember these per-window options across the closing and re-opening of a file." Original comment by jfkth...@gmail.com on 12 Nov 2009 at 10:34

Personal use suggests the tick box is for a new file whilst existing files generally "remember" their setting from past file history so You need to toggle "off" or "on" each windowed file prior to closing.

To speed this task up you can set a shortcut (Authors suggestion is to set F4 to line_numbers) see the manual at https://github.com/TeXworks/manual


if you wanted it to be done for reviewing purposes within the document, you could also use this in your preamble:


For more variation, refer here

  • 1
    I'm pretty sure that affects the exported .pdf (output), not the editor. – IdleCustard Jan 22 at 18:40
  • Indeed it does. As it is often the need to have line numbers within your pdf, I mentioned it as an option here. – Darya Shcherbakova Jan 22 at 19:17
  • Also please don't mind me wondering, but it there are a specific reason you are using TexWorks? I've been using Latex for years, and my personal favorite editor is TexStudio, really convenient for writing/editing if you want to use as much GUI for customization/help in styling etc. – Darya Shcherbakova Jan 22 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.