Skip to content

Instantly share code, notes, and snippets.

@SHDShim
Last active November 13, 2024 08:16
Show Gist options
  • Save SHDShim/717fd9f60f98f85eee5e70831d6ac8a0 to your computer and use it in GitHub Desktop.
Save SHDShim/717fd9f60f98f85eee5e70831d6ac8a0 to your computer and use it in GitHub Desktop.

Revisions

  1. SHDShim revised this gist Jan 13, 2024. 1 changed file with 10 additions and 4 deletions.
    14 changes: 10 additions & 4 deletions latex2word.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,8 @@
    ## LaTeX to WORD conversion
    # LaTeX to WORD conversion

    **In most cases, it is simpler to (1) read a PDF file directly in WORD, or (2) use save as function in Acrobat Reader to save as a DOC file.**

    ## Install Pandoc

    `Pandoc` can be installed in anaconda by

    @@ -12,6 +16,8 @@ or in brew.
    brew install pandoc
    ```

    ## How to use

    I strongly recommand to use brew version. For brew, switch to the brew environment first.

    ```
    @@ -34,7 +40,7 @@ Change the file names appropriately.
    - Do not place both `-F pandoc-crossref` and `--citeproc` at the same time, it will repeat the figure and table caption titles.
    - Note that renumbering for figures and tables (for example S1 for supplementary contents) are all ignored. So be careful if this is important.

    ## For numbered citations, such as Nature and Science
    ### For numbered citations, such as Nature and Science

    ```
    pandoc --citeproc -f latex -s Nature-main\ text.tex --csl=../nature.csl -o main.docx --bibliography=B30.bib
    @@ -43,13 +49,13 @@ Source: https://tex.stackexchange.com/questions/268196/how-to-convert-latex-to-w

    `*.csl` can be donwloaded from: https://github.com/citation-style-language/styles. A range of journal format is available there.

    ## Word to LaTeX conversion
    ### Word to LaTeX conversion

    ```
    pandoc -t latex -f docx in.docx -o out.tex
    ```

    ## LaTeX to html conversion
    ### LaTeX to html conversion

    ```
    pandoc -F pandoc-crossref --citeproc --mathjax -f latex -t html -s FeSH-JGR.tex -o FeSH-JGR.html --bibliography=FeSH.bib
  2. SHDShim revised this gist Oct 26, 2021. 1 changed file with 0 additions and 33 deletions.
    33 changes: 0 additions & 33 deletions latex2word.md
    Original file line number Diff line number Diff line change
    @@ -43,39 +43,6 @@ Source: https://tex.stackexchange.com/questions/268196/how-to-convert-latex-to-w

    `*.csl` can be donwloaded from: https://github.com/citation-style-language/styles. A range of journal format is available there.

    ## Remove TrackChanges

    If you have track change commands from the `TrackChanges` package (not the `changes` package), the commands can be removed by:

    ```
    python ../acceptchanges.py -c -n --infile=0-main.tex --outfile=0-main-no-track.tex
    ```

    - Note that `acceptchanges.py` works only with `python v2.7`.
    - The `acceptchanges.py` can be found under `TrackChanges` folder or it comes with the latex package.
    - `acceptchanges.py` does not automatically deal with `\input{}` or `\include{}` files. So I have to process with `acceptchanges.py` all associated files individually.
    - For the command above to work, copy entire latex folder under `/trackchanges-0.7.0/PythonPackage/` folder.

    ## Remove Changes

    For latex `changes` package was used for track change, use `pyMergeChanges.py`.

    ```
    python ../pyMargeChanges.py -a input.tex output.tex # python 3
    ```

    ## Remove comments and organize files for submission

    Under the `base` environment of `anaconda`, I installed `arxiv_latex_cleaner` (https://github.com/google-research/arxiv-latex-cleaner).

    ```
    arxiv_latex_cleaner Hydrogen_FeS_paper/ --im_size 500
    ```

    - This will create organized package in a new folder, `Hydrogen_FeS_paper_arXiv`.
    - `arxiv_latex_cleaner` seems to know how to deal with `\include{}` and `\input{}`. It also deals well with `bibunits`.


    ## Word to LaTeX conversion

    ```
  3. SHDShim revised this gist Oct 26, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions latex2word.md
    Original file line number Diff line number Diff line change
    @@ -37,11 +37,11 @@ Change the file names appropriately.
    ## For numbered citations, such as Nature and Science

    ```
    pandoc --citeproc -f latex -s Nature-main\ text.tex --csl=../ieee.csl -o main.docx --bibliography=B30.bib
    pandoc --citeproc -f latex -s Nature-main\ text.tex --csl=../nature.csl -o main.docx --bibliography=B30.bib
    ```
    Source: https://tex.stackexchange.com/questions/268196/how-to-convert-latex-to-word-using-pandoc-and-keep-citations-as-numeral

    `ieee.csl` can be donwloaded from: https://github.com/citation-style-language/styles
    `*.csl` can be donwloaded from: https://github.com/citation-style-language/styles. A range of journal format is available there.

    ## Remove TrackChanges

  4. SHDShim revised this gist Oct 26, 2021. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions latex2word.md
    Original file line number Diff line number Diff line change
    @@ -34,6 +34,15 @@ Change the file names appropriately.
    - Do not place both `-F pandoc-crossref` and `--citeproc` at the same time, it will repeat the figure and table caption titles.
    - Note that renumbering for figures and tables (for example S1 for supplementary contents) are all ignored. So be careful if this is important.

    ## For numbered citations, such as Nature and Science

    ```
    pandoc --citeproc -f latex -s Nature-main\ text.tex --csl=../ieee.csl -o main.docx --bibliography=B30.bib
    ```
    Source: https://tex.stackexchange.com/questions/268196/how-to-convert-latex-to-word-using-pandoc-and-keep-citations-as-numeral

    `ieee.csl` can be donwloaded from: https://github.com/citation-style-language/styles

    ## Remove TrackChanges

    If you have track change commands from the `TrackChanges` package (not the `changes` package), the commands can be removed by:
  5. SHDShim revised this gist Aug 7, 2021. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions latex2word.md
    Original file line number Diff line number Diff line change
    @@ -47,6 +47,14 @@ python ../acceptchanges.py -c -n --infile=0-main.tex --outfile=0-main-no-track.t
    - `acceptchanges.py` does not automatically deal with `\input{}` or `\include{}` files. So I have to process with `acceptchanges.py` all associated files individually.
    - For the command above to work, copy entire latex folder under `/trackchanges-0.7.0/PythonPackage/` folder.

    ## Remove Changes

    For latex `changes` package was used for track change, use `pyMergeChanges.py`.

    ```
    python ../pyMargeChanges.py -a input.tex output.tex # python 3
    ```

    ## Remove comments and organize files for submission

    Under the `base` environment of `anaconda`, I installed `arxiv_latex_cleaner` (https://github.com/google-research/arxiv-latex-cleaner).
  6. SHDShim revised this gist Aug 7, 2021. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion latex2word.md
    Original file line number Diff line number Diff line change
    @@ -31,7 +31,8 @@ Change the file names appropriately.
    - Run multiples of time (unconfirmed).
    - `Pandoc` knows how to deal with `bibunits` and `\input{}`.
    - Note that `line number` referencing and citing do not work with `pandoc`.
    - Do not place both `-F pandoc-crossref` and `--citeproc` at the same time, it will repeat the figure and table caption titles.
    - Do not place both `-F pandoc-crossref` and `--citeproc` at the same time, it will repeat the figure and table caption titles.
    - Note that renumbering for figures and tables (for example S1 for supplementary contents) are all ignored. So be careful if this is important.

    ## Remove TrackChanges

  7. SHDShim revised this gist Aug 7, 2021. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions latex2word.md
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,7 @@ swt_brew # custom command in .bash_profile
    Then go to the folder where you have `.tex` files to convert. Run the following command:

    ```
    pandoc -F pandoc-crossref --citeproc -f latex -s FeSH-JGR.tex -o FeSH-JGR.docx --bibliography=FeSH.bib
    pandoc --citeproc -f latex -s FeSH-JGR.tex -o FeSH-JGR.docx --bibliography=FeSH.bib
    ```

    Change the file names appropriately.
    @@ -31,6 +31,7 @@ Change the file names appropriately.
    - Run multiples of time (unconfirmed).
    - `Pandoc` knows how to deal with `bibunits` and `\input{}`.
    - Note that `line number` referencing and citing do not work with `pandoc`.
    - Do not place both `-F pandoc-crossref` and `--citeproc` at the same time, it will repeat the figure and table caption titles.

    ## Remove TrackChanges

    @@ -71,4 +72,4 @@ pandoc -F pandoc-crossref --citeproc --mathjax -f latex -t html -s FeSH-JGR.tex
    For better outcome to html:
    - convert all pdf figures to png figures
    - `\multicolumn` is not compatible with `pandoc`
    - Figure and table labelings are not made properly.
    - Figure labelings are properly done, but not for table labeling. I try everything but so far the line above is the best. If you remove any of `-F pandoc-crossref` and `--citeproc` from the line above, it will mess up the citations.
  8. SHDShim revised this gist Aug 7, 2021. 1 changed file with 23 additions and 17 deletions.
    40 changes: 23 additions & 17 deletions latex2word.md
    Original file line number Diff line number Diff line change
    @@ -6,49 +6,55 @@
    conda install pandoc
    ```

    or in brew. For brew, switch to brew environment first.
    or in brew.

    ```
    brew install pandoc
    ```

    I strongly recommand to use brew version. For brew, switch to the brew environment first.

    ```
    swt_brew # custom command in .bash_profile
    ```

    Then go to the folder where you have `.tex` file to convert. Run the following command:
    Then go to the folder where you have `.tex` files to convert. Run the following command:

    ```
    pandoc -F pandoc-crossref --citeproc -f latex -s FeSH-JGR.tex -o FeSH-JGR.docx --bibliography=FeSH.bib
    ```

    The command works only with `brew` version of `pandoc` for me. Change the file names appropriately.
    Change the file names appropriately.

    Note that the order betweeen `pandoc-crossref` and `citeproc` should not change. Run multiples of time (unconfirmed).

    `pandoc` knows how to deal with `bibunits` and `\input{}`. Note that `line number` referencing and citing do not work with `pandoc`.
    - The command works only with `brew` version of `pandoc` for me.
    - Note that the order betweeen `pandoc-crossref` and `citeproc` should not change.
    - Run multiples of time (unconfirmed).
    - `Pandoc` knows how to deal with `bibunits` and `\input{}`.
    - Note that `line number` referencing and citing do not work with `pandoc`.

    ## Remove TrackChanges

    If you have tracking commands from `TrackChanges` package (not `changes` package), the commands can be removed by:
    If you have track change commands from the `TrackChanges` package (not the `changes` package), the commands can be removed by:

    ```
    python ../acceptchanges.py -c -n --infile=0-main.tex --outfile=0-main-no-track.tex
    ```

    Note that `acceptchanges.py` works only with `python v2.7`. The `acceptchanges.py` can be found under `TrackChanges` folder or it comes with the latex package.

    `acceptchanges.py` does not automatically deal with `\input{}` or `\include{}` files. So I have to process with `acceptchanges.py` all associated files individually.
    - Note that `acceptchanges.py` works only with `python v2.7`.
    - The `acceptchanges.py` can be found under `TrackChanges` folder or it comes with the latex package.
    - `acceptchanges.py` does not automatically deal with `\input{}` or `\include{}` files. So I have to process with `acceptchanges.py` all associated files individually.
    - For the command above to work, copy entire latex folder under `/trackchanges-0.7.0/PythonPackage/` folder.

    For the command above to work, copy entire latex folder under `/trackchanges-0.7.0/PythonPackage/` folder.
    ## Remove comments and organize files for submission

    ## Remove comments and organize for submission

    Under base environment, I installed `arxiv_latex_cleaner` (https://github.com/google-research/arxiv-latex-cleaner).
    Under the `base` environment of `anaconda`, I installed `arxiv_latex_cleaner` (https://github.com/google-research/arxiv-latex-cleaner).

    ```
    arxiv_latex_cleaner Hydrogen_FeS_paper/ --im_size 500
    ```

    This will create organized package in a new folder, `Hydrogen_FeS_paper_arXiv`.

    `arxiv_latex_cleaner` seems to know how to deal with `\include{}` and `\input{}`. It also deals well with `bibunits`.
    - This will create organized package in a new folder, `Hydrogen_FeS_paper_arXiv`.
    - `arxiv_latex_cleaner` seems to know how to deal with `\include{}` and `\input{}`. It also deals well with `bibunits`.


    ## Word to LaTeX conversion
  9. SHDShim revised this gist Aug 7, 2021. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions latex2word.md
    Original file line number Diff line number Diff line change
    @@ -60,8 +60,9 @@ pandoc -t latex -f docx in.docx -o out.tex
    ## LaTeX to html conversion

    ```
    pandoc text-main.tex -f latex -t html -s -o text-main.html --mathjax --bibliograph=B30.bib --citeproc
    pandoc -F pandoc-crossref --citeproc --mathjax -f latex -t html -s FeSH-JGR.tex -o FeSH-JGR.html --bibliography=FeSH.bib
    ```
    For better outcome to html:
    - convert all pdf figures to png figures
    - `\multicolumn` is not compatible with `pandoc`
    - `\multicolumn` is not compatible with `pandoc`
    - Figure and table labelings are not made properly.
  10. SHDShim revised this gist Aug 7, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion latex2word.md
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ swt_brew # custom command in .bash_profile
    Then go to the folder where you have `.tex` file to convert. Run the following command:

    ```
    pandoc -s FeSH-JGR.tex -F pandoc-crossref --citeproc -f latex -o FeSH-JGR.docx --bibliography=FeSH.bib
    pandoc -F pandoc-crossref --citeproc -f latex -s FeSH-JGR.tex -o FeSH-JGR.docx --bibliography=FeSH.bib
    ```

    The command works only with `brew` version of `pandoc` for me. Change the file names appropriately.
  11. SHDShim revised this gist Aug 7, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion latex2word.md
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@ Note that the order betweeen `pandoc-crossref` and `citeproc` should not change.

    ## Remove TrackChanges

    If you have track changes, the command can be removed by:
    If you have tracking commands from `TrackChanges` package (not `changes` package), the commands can be removed by:

    ```
    python ../acceptchanges.py -c -n --infile=0-main.tex --outfile=0-main-no-track.tex
  12. SHDShim revised this gist Aug 7, 2021. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion latex2word.md
    Original file line number Diff line number Diff line change
    @@ -32,7 +32,9 @@ If you have track changes, the command can be removed by:
    python ../acceptchanges.py -c -n --infile=0-main.tex --outfile=0-main-no-track.tex
    ```

    Not that `acceptchanges.py` works only with `python v2.7`. The `acceptchanges.py` can be found under `TrackChanges` folder or it comes with the latex package.
    Note that `acceptchanges.py` works only with `python v2.7`. The `acceptchanges.py` can be found under `TrackChanges` folder or it comes with the latex package.

    `acceptchanges.py` does not automatically deal with `\input{}` or `\include{}` files. So I have to process with `acceptchanges.py` all associated files individually.

    For the command above to work, copy entire latex folder under `/trackchanges-0.7.0/PythonPackage/` folder.

    @@ -46,6 +48,8 @@ arxiv_latex_cleaner Hydrogen_FeS_paper/ --im_size 500

    This will create organized package in a new folder, `Hydrogen_FeS_paper_arXiv`.

    `arxiv_latex_cleaner` seems to know how to deal with `\include{}` and `\input{}`. It also deals well with `bibunits`.


    ## Word to LaTeX conversion

  13. SHDShim revised this gist Aug 7, 2021. 1 changed file with 12 additions and 1 deletion.
    13 changes: 12 additions & 1 deletion latex2word.md
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ Note that the order betweeen `pandoc-crossref` and `citeproc` should not change.

    `pandoc` knows how to deal with `bibunits` and `\input{}`. Note that `line number` referencing and citing do not work with `pandoc`.

    ## TrackChanges
    ## Remove TrackChanges

    If you have track changes, the command can be removed by:

    @@ -36,6 +36,17 @@ Not that `acceptchanges.py` works only with `python v2.7`. The `acceptchanges.p

    For the command above to work, copy entire latex folder under `/trackchanges-0.7.0/PythonPackage/` folder.

    ## Remove comments and organize for submission

    Under base environment, I installed `arxiv_latex_cleaner` (https://github.com/google-research/arxiv-latex-cleaner).

    ```
    arxiv_latex_cleaner Hydrogen_FeS_paper/ --im_size 500
    ```

    This will create organized package in a new folder, `Hydrogen_FeS_paper_arXiv`.


    ## Word to LaTeX conversion

    ```
  14. SHDShim revised this gist Aug 7, 2021. 1 changed file with 24 additions and 2 deletions.
    26 changes: 24 additions & 2 deletions latex2word.md
    Original file line number Diff line number Diff line change
    @@ -6,13 +6,35 @@
    conda install pandoc
    ```

    or in brew. For brew, switch to brew environment first.

    ```
    swt_brew # custom command in .bash_profile
    ```

    Then go to the folder where you have `.tex` file to convert. Run the following command:

    ```
    pandoc --filter pandoc-tablenos -s text-main.tex --bibliography=B30.bib --citeproc -f latex -o text-main.docx
    pandoc -s FeSH-JGR.tex -F pandoc-crossref --citeproc -f latex -o FeSH-JGR.docx --bibliography=FeSH.bib
    ```

    Change the file names appropriately.
    The command works only with `brew` version of `pandoc` for me. Change the file names appropriately.

    Note that the order betweeen `pandoc-crossref` and `citeproc` should not change. Run multiples of time (unconfirmed).

    `pandoc` knows how to deal with `bibunits` and `\input{}`. Note that `line number` referencing and citing do not work with `pandoc`.

    ## TrackChanges

    If you have track changes, the command can be removed by:

    ```
    python ../acceptchanges.py -c -n --infile=0-main.tex --outfile=0-main-no-track.tex
    ```

    Not that `acceptchanges.py` works only with `python v2.7`. The `acceptchanges.py` can be found under `TrackChanges` folder or it comes with the latex package.

    For the command above to work, copy entire latex folder under `/trackchanges-0.7.0/PythonPackage/` folder.

    ## Word to LaTeX conversion

  15. SHDShim revised this gist Aug 1, 2021. 1 changed file with 11 additions and 2 deletions.
    13 changes: 11 additions & 2 deletions latex2word.md
    Original file line number Diff line number Diff line change
    @@ -14,8 +14,17 @@ pandoc --filter pandoc-tablenos -s text-main.tex --bibliography=B30.bib --citepr

    Change the file names appropriately.

    ## Word to LaTex conversion
    ## Word to LaTeX conversion

    ```
    pandoc -t latex -f docx in.docx -o out.tex
    ```
    ```

    ## LaTeX to html conversion

    ```
    pandoc text-main.tex -f latex -t html -s -o text-main.html --mathjax --bibliograph=B30.bib --citeproc
    ```
    For better outcome to html:
    - convert all pdf figures to png figures
    - `\multicolumn` is not compatible with `pandoc`
  16. SHDShim revised this gist Jul 31, 2021. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion latex2word.md
    Original file line number Diff line number Diff line change
    @@ -12,4 +12,10 @@ Then go to the folder where you have `.tex` file to convert. Run the following
    pandoc --filter pandoc-tablenos -s text-main.tex --bibliography=B30.bib --citeproc -f latex -o text-main.docx
    ```

    Change the file names appropriately.
    Change the file names appropriately.

    ## Word to LaTex conversion

    ```
    pandoc -t latex -f docx in.docx -o out.tex
    ```
  17. SHDShim revised this gist Jul 21, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion latex2word.md
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ conda install pandoc
    Then go to the folder where you have `.tex` file to convert. Run the following command:

    ```
    pandoc text-main.tex --citeproc --bibliography=B30.bib -o text-main.docx
    pandoc --filter pandoc-tablenos -s text-main.tex --bibliography=B30.bib --citeproc -f latex -o text-main.docx
    ```

    Change the file names appropriately.
  18. SHDShim revised this gist Jul 21, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions latex2word.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    ## LaTeX to WORD conversion

    `Pandoc` can be installed in anaconda by

    ```
  19. SHDShim created this gist Jul 21, 2021.
    13 changes: 13 additions & 0 deletions latex2word.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    `Pandoc` can be installed in anaconda by

    ```
    conda install pandoc
    ```

    Then go to the folder where you have `.tex` file to convert. Run the following command:

    ```
    pandoc text-main.tex --citeproc --bibliography=B30.bib -o text-main.docx
    ```

    Change the file names appropriately.