1

As of now I have tried two ways of writing a large document (over 100 pages), one is to have everything (even the bibliography) in one single .tex file, and the other is to split the document into smaller files, for example, by chapters.

Each ways have their merit but neither is perfect

  • Using one single file is clunky.
  • While multi-file has more clarity, but it is inconvenient for one reason: say I changed the key for a reference item, I have to go over all the sub-files and search for possible occurrences of that key. Whereas if I had one file, I only have to search once and click "replace all".

Is there a better practice for writing a large document? Thank you in advance!

zyy
  • 2,146
  • 5
    This depends on your editor. If you use emacs or xemacs, tags-query-replace will automatically search and replace in all of your files. – Phil Hirschhorn Mar 24 '21 at 02:34
  • Which editor do you use? Does it provide code and text folding? – Mico Mar 24 '21 at 03:00
  • Hmmm, put all your keys into macros which are defined in the preamble file? – John Kormylo Mar 24 '21 at 03:01
  • 1
    I'd use sed -i 's/old/new/g' over as many files as necessary. – Erwann Mar 24 '21 at 03:12
  • 2
    any reasonable editor will let you do a replace over multiple files, but changing the label key should be a relatively rare occurrence, why are you needing to change the key often enough that it is an issue? I would expect that in most documents you never need to do that even if editing it over several months – David Carlisle Mar 24 '21 at 08:36
  • Why would you ever want to change the key for a reference item? In general for a "large" document have each chapter in a separate file (not in subdirectories) and use \include and \includeonly in the main file. – Peter Wilson Mar 24 '21 at 18:05
  • @Mico I use TexShop on Mac, maybe with code folding it could be easier to navigate. – zyy Mar 25 '21 at 01:29
  • @Erwann Thanks, that could be a good choice, but maybe it is better to look at each occurrences before clicking the button, so that leads to searching in each subfiles again... – zyy Mar 25 '21 at 01:32
  • 1
    @DavidCarlisle I agree, it is a rare occurrence, but it happens when you are collaboratively editing a document and someone did not like the convention you chose for the citation keys... – zyy Mar 25 '21 at 01:34
  • @DavidCarlisle By the way, could you maybe name such an editor on Mac? It is even better if I can scan over all the occurrences in all the subfiles so that I can make sure I am replacing the right thing. Thanks! – zyy Mar 25 '21 at 01:36
  • @JohnKormylo That would give me two keys in stead of one that are tempting to be changed sometime later? – zyy Mar 25 '21 at 01:40
  • 1
    @zyy I don't know what you mean by "clicking the button". If you're saying sed -i is unsafe, you can create safeguards, such as backups and user confirmation, etc. That's a question for unix.stackexchange.com. – Erwann Mar 25 '21 at 03:41
  • I'm familiar with both TeXshop and TeXworks. (I'm a Mac and MacTeX user as well.) Unfortunately, neither provides code folding. If you haven't already done so, do have a look at the posting LaTeX Editors/IDEs. Some MacOS-compatible editors do provide code folding. Unfortunately, some of these fancier editors do a very good a job -- much too good a job, in my view -- of hiding TeX warning and error messages, pretty much guaranteeing that users will never learn how to make sense of such messages. Sigh. – Mico Mar 25 '21 at 05:31
  • I have used the same editor (emacs) on all platforms I have used, more or less every day, since 1987 so based on a sample size of 1 I could suggest emacs. – David Carlisle Mar 25 '21 at 08:23
  • @Mico Thanks! In my case, I used to be copying and pasting whatever solutions found on the internet without knowing what they do. But over time, I slowly found myself making sense of the code and reading the documentations. Nowadays the editors are getting fancier and the process may take much longer! – zyy Mar 25 '21 at 13:14
  • @DavidCarlisle Thanks, I use vim for writing codes. But when it comes to editing LaTeX with vim, I find that navigating long sentences is cumbersome. I should setup vim differently for LaTeX so that it is easier! – zyy Mar 25 '21 at 13:19
  • Between your two choices (one document or multiple parts), the best practice is to decide in advance where you prefer to tackle the administrative overhead given the tools that are at your disposal. Since you mention collaborative work, it also may mean assigning one person in advance to be in charge of assuring that the team’s inputs and editing changes are aligned to one standard and giving that person some authority to define the base conventions on how the inputs should be delivered. – Jeffrey J Weimer Mar 26 '21 at 13:41
  • @JeffreyJWeimer That is a good point, thanks! – zyy Mar 26 '21 at 17:13

0 Answers0