5  When Co-authors Edit in Word

Everything so far works very well while you are writing the qmd alone. Eventually, though, co-authors (your supervisor, collaborators) review the paper, and most of them edit with tracked changes and comments in Word.

The problem is that there is no way to bring Word edits back into the qmd. You can only fix the qmd by hand while looking at the tracked-changes docx. After several rounds, that alone becomes a big burden.

5.1 Split the work into two phases

So we switch “which manuscript is the master copy” by phase.

flowchart LR
  subgraph A["Phase A: up to the first draft"]
    q["qmd is the master"] --> d1["render → docx"]
  end
  subgraph B["Phase B: after sending to co-authors"]
    w["Word is the master"] --> r["co-authors edit"] --> w
  end
  d1 -- "send first draft<br/>save a numbers snapshot" --> w
  t["analysis changed"] -. "numbers_diff:<br/>only changed numbers" .-> w

Phase A (up to the first draft) Phase B (after sending to co-authors)
Master copy qmd Word (docx)
Editing prose Edit the qmd and render Edit in Word (don’t port back to the qmd)
When numbers change Just tar_make() and render Check changed numbers with numbers_diff and replace them in Word
When tables/figures change Just tar_make() tar_make() and swap the files

Even in Phase B, tables and figures are separate files, so they can simply be rebuilt and swapped in. The only thing you have to fix by hand is “numbers in the body text”. That is what numbers_diff helps with.

5.2 Take a snapshot of the numbers

When you send the manuscript to co-authors, save a snapshot of the numbers in the text at that point.

Rscript scripts/checks/numbers_diff.R --save
控えを保存: results/numbers_20261123_1855.json      (= "snapshot saved")

The snapshot is simply the num$xxx names and values written out as JSON.

results/numbers_20261123_1855.json (excerpt)
{
  "n_all": "600",
  "n_sarc": "127",
  "prev_all": "21.2%",
  "or_long_high": "odds ratio 0.34, 95% confidence interval 0.16–0.68, P = 0.003",
  "or_short_high": "OR 0.34, 95% CI 0.16–0.68, P = 0.003"
}

Commit results/ to git. It becomes a record of which numbers you gave your co-authors, and when.

5.3 When the analysis changes, check only the numbers that changed

Suppose that in Phase B you decide, “let’s drop diabetes from the adjustment after all”.

  1. Edit models.R
  2. Recompute with tar_make() (tables and figures are rebuilt automatically)
  3. Run numbers_diff.R
Rscript scripts/checks/numbers_diff.R
比較: results/numbers_20261123_1855.json → 今の結果

■ or_long_high
  旧: odds ratio 0.34, 95% confidence interval 0.16–0.68, P = 0.003
  新: odds ratio 0.32, 95% confidence interval 0.15–0.63, P = 0.001
  使用箇所: manuscript/jcsm/sections/_01_abstract.qmd:9

■ or_long_moderate
  旧: odds ratio 0.80, 95% confidence interval 0.47–1.35, P = 0.397
  新: odds ratio 0.78, 95% confidence interval 0.46–1.31, P = 0.347
  使用箇所: manuscript/jcsm/sections/_01_abstract.qmd:9

■ or_short_high
  旧: OR 0.34, 95% CI 0.16–0.68, P = 0.003
  新: OR 0.32, 95% CI 0.15–0.63, P = 0.001
  使用箇所: manuscript/jcsm/sections/_04_results.qmd:9
  ...

5 件変更。Word では「旧」で検索して「新」に置き換える(表・図はファイルごと差し替え)

The sample prints its labels in Japanese: 比較 = comparing, 旧 = old, 新 = new, 使用箇所 = used at, and the last line says “5 changed. In Word, search for the old string and replace it with the new one (swap tables and figures as files)”.

All that is left is to search Word for each “old” string and replace it with the “new” one. Every changed number has been listed, so nothing slips through.

TipTake a new snapshot after replacing

When you have finished editing in Word, take a new snapshot with --save. The next time the analysis changes, you will compare against that one.

5.4 Reviewing docx files returned by co-authors

Save returned docx files in manuscript/jcsm/review/ with names that show version, date and who it came from.

manuscript/jcsm/review/
├─ v1_20261201_sent.docx
├─ v2_20261215_supervisor.docx
└─ v3_20270110_collaboratorA.docx

With many tracked changes and comments, it can be hard to get an overview on the Word screen. review_extract.sh exports the docx to markdown with tracked changes and comments preserved.

bash scripts/checks/review_extract.sh manuscript/jcsm/review/v2_20261215_supervisor.docx
#> → manuscript/jcsm/review/v2_20261215_supervisor.md

Under the hood it uses Pandoc’s --track-changes=all.

scripts/checks/review_extract.sh
for f in "$@"; do
  out="${f%.docx}.md"
  quarto pandoc "$f" --track-changes=all -t markdown --wrap=none -o "$out"
  echo "→ $out"
done

In the exported markdown, insertions, deletions and comments remain marked like this:

Physical activity is a [modifiable]{.insertion author="Supervisor"} factor ...
[may help]{.deletion author="Supervisor"} ...
[Please add a reference here]{.comment-start id="0" author="Supervisor"} ...

Search for .comment-start in nvim or your editor to list only the comments.

5.5 When to switch phases

A good rule of thumb is when you first send the manuscript to your co-authors.

  • Right before sending, do one last render from the qmd
  • Take a snapshot with numbers_diff.R --save
  • Save the docx you sent as review/v1_<date>_sent.docx
  • From here on, Word is the master copy
WarningDon’t edit the qmd in Phase B

If you edit prose in the qmd after entering Phase B, it drifts away from the Word file. Make prose edits only in Word, and use the qmd as “a tool for producing numbers, tables and figures”.

5.6 Summary

  • Up to the first draft, the qmd is the master (Phase A); after sending to co-authors, Word is the master (Phase B)
  • When sending, snapshot the numbers in the text with numbers_diff.R --save
  • When the analysis changes, use numbers_diff.R to see “old → new” and where each is used, then replace them in Word
  • Swap tables and figures as whole files
  • Save co-authors’ docx files in review/ with version and date, and inspect them with review_extract.sh