Peter Hsiao
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- tags: LaTeX, markdown, R, 排版 --- # 快速上手數學報告(0) - LaTeX 你會用到跟不會用到的種種工具 [TOC] ***==注意!== 這裡面的解釋簡化了許多東西,並非正確說法,有需要近一步學習請至各大網站學習*** ## $\LaTeX$ 概述 $\LaTeX$ 是甚麼? - `.tex` 檔:$\LaTeX$ 是一種[==**標記語言**==](https://zh.wikipedia.org/wiki/%E7%BD%AE%E6%A0%87%E8%AF%AD%E8%A8%80),意思是: $\LaTeX$ 這種 ==**語法**==,是用來在[==**純文字檔案**==](https://zh.wikipedia.org/wiki/%E6%96%87%E6%9C%AC%E6%96%87%E4%BB%B6)中,標記文字排版[^1]格式,供能執行此語法的排版軟體進行排版,雖然是純文字檔,為了相關軟體辨識方便,一般附檔名會改成 `.tex`,跟 `.csv`, `.html`, `.css` 這些常見的文檔是一樣的道理 - $\LaTeX$ 套件:把 $\LaTeX$ 文件變成排版後的可印刷文件(例如:PDF)的軟體,這個輸出的過程叫做 ==**編譯**== - $\LaTeX$ 編輯器:所有的編輯器[^2]都能編輯 `.tex` 檔,可以幫助你執行$\LaTeX$ 套件將 `.tex`文件輸出成長得像論文的 `.pdf`,也有專門的 $\LaTeX$ 編輯器,能做到一站式作業 > 使用 $\LaTeX$ 時請務必記得這三個是分開的,要製造 `.tex` 文檔不一定非要某幾個特定編輯器,同一個編輯器也可以透過不同的套件對文檔編譯 ### 要學甚麼?(依個人主觀優先順序排序) 0. 計算機概論,尤其是檔案格式這件事情(至少要理解附檔名、純文字檔、命令列軟體、使用者介面這些事情) 1. 數學式寫法: $\LaTeX$ 數學式表達已經幾乎是通用標準,就算你只是用 MS Word 開方程式編輯器,也可以貼上 $\LaTeX$ 數學式並轉換(2016版某次更新之後),不熟時可使用這個網站輔助 https://www.codecogs.com/latex/eqneditor.php 2. 符號:不用特別背,但要觀察其命名邏輯,符號表 http://tug.ctan.org/info/symbols/comprehensive/symbols-a4.pdf 3. 語法結構:可參考 http://www.cs.nthu.edu.tw/~cherung/teaching/2009cs5321/link/latex.pdf (還有很多教學網站資料) 4. BiBTeX:寫論文要管理文獻用 5. Beamer:做簡報用,教學可見[維基百科](https://zh.wikipedia.org/wiki/Beamer_(LaTeX))給的連結 ### $\LaTeX$ 軟體表 #### 編輯器 ##### 程式編輯器+外掛 可自我訂製功能,可以整合其他程式碼,且多數編輯器 Win、Mac、Linux 平台都有,但缺點就是 $\LaTeX$ 相關功能陽春 - [Vim](https://vim.sourceforge.io/) ([Vim-LaTeX](http://vim-latex.sourceforge.net/)):開源免費難學、老牌、執行效率快,高手向,初學勿碰,鄙視下面的使用者 - [Emacs](https://www.gnu.org/software/emacs/) ([AUC$\TeX$](http://www.gnu.org/software/auctex/)) :開源免費難學、老牌、執行效率快,高手向,初學勿碰,鄙視上面的使用者 - ==[VS Code](https://code.visualstudio.com/)== ([LaTeX Workshop](https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop)):開源免費易學、執行效率普普、外掛很多樣,微軟老大維護,推薦使用,但會被其他使用者鄙視 - [Sublime Text](https://www.sublimetext.com/) ([LaTeXTools](https://latextools.readthedocs.io/)):半付費易學,執行效率果粉碼農吹爆,介面漂亮,功能強大,但更新社群不活躍 - [Atom](https://atom.io/) ([LaTeX Package](https://atom.io/packages/latex)):開源免費易學、執行效率很差、外掛很多樣,GitHub 社群護航 ##### 正規 $\LaTeX$ 編輯器: - [WinEdt](www.winedt.com/) (Windows):要錢免談 - ==[TeXmaker](http://www.xm1math.net/texmaker/)== (Windows, Mac OS, Linux):免費易學、介面漂亮,一般推薦這個 - ==[TeXstudio](https://www.texstudio.org/)== (Windows, Mac OS, Linux):免費易學、介面不漂亮但功能比上一個齊全(尤其是多重選取編輯),一般推薦這個 - [LyX](https://www.lyx.org/) (Windows, Mac OS, Linux):免費易學、介面不漂亮,像老版的 Word 可以做到所見即所得 - [Scientific Word](https://www.mackichan.com/index.html?products/snb.html~mainFrame) (Windows, Mac OS):要錢、介面有點老,像老版的 Word 可以做到所見即所得(有點非正統) #### 套件 - [MiKTeX](https://miktex.org/):僅限 Windows,個人經驗,安裝時請用 [Net Installer](https://miktex.org/download) 安裝所有 Package 比較省事,不然後面 Package 缺東缺西的很麻煩。 - [TeX Live](https://www.tug.org/texlive/): Win、Mac、Linux 平台都有 > 假如你兩個套件都安裝了,前一節敘述的編輯器都能設定要用哪個套件編譯 #### 網站服務 好處在於不用安裝,壞處在於沒有安裝 - [Overleaf](https://www.overleaf.com/):最大牌,免費僅限一個專案,最近剛吃掉 ShareLaTeX 所以不提 ShareLaTeX - [papeeria](https://www.papeeria.com) - [latexbase](https://latexbase.com) ### 其他輔助軟體、網站 - [Inkscape](https://inkscape.org/zh-hant/):向量圖編輯軟體,主要是畫流程圖用的,免費 - [JabRef](http://www.jabref.org/):BiBTeX 軟體,編 reference 用,免費 - [Table Generator](http://www.tablesgenerator.com/):表格產生器(推薦!) --- ## 不碰 $\LaTeX$ 的方法 ### Markdown + pandoc + 開源軟體 = 無痛輸出 $\LaTeX$ [Markdown](https://markdown.tw/) 是易讀性最高的標記語言,其原始碼跟一般純文字電子郵件沒甚麼兩樣其基本語法如下 ```markdown= # 1階標題 ## 2階標題 ### 3階標題 #### 4階標題 ##### 5階標題 ###### 6階標題 內文 下一個段落的內文(空一行) 下一個層級的內文 再下一個層級的內文 同級內文不分行(會有空格) - 無序項目 - 無序項目 - 下一個層級無序項目 1. 有序項目(第一個可指定開始序號例如0.) 3. 除第一項不需要順序,編譯時電腦會幫你自動排序 2. 下一個層級有序項目 - 同層級無序項目(可以混編) [連結](連結URL) $行內數學式$ $$ 數學式 $$ ``` > ==**注意!**== Markdown 的功能陽春,很多團體製作的 Markdown App 會支援擴展語法,詳細還需看各家設定,我上面列的是多數廠家支援的格式 [pandoc](https://pandoc.org/) 是一個標記語言轉換軟體,假如你安裝 R 的免費 IDE - [R Studio](https://www.rstudio.com/) 會因為裡面有 [Rmarkdown](https://rmarkdown.rstudio.com/) 而順便安裝,但還是建議自行更新到最新版 真正厲害的地方在於,pandoc + Markdown 的組合可以很快速的生出各種標記語言的文本,以至於眾多開發者開始使用 Markdown 作為個人知識庫使用,加上 GitHub 要求用 Markdown 寫 Readme,所以很多自由軟體專案都在開發基於這個組合的各種軟體,那這個事實如何有助於我們寫 $\LaTeX$ 論文呢? 我們可以先去找一個 Markdown 軟體,長得有點像 Word,先打好草稿,再轉成 `.tex` 文件,丟給 $\LaTeX$ 編輯器去調整模板最後輸出 ### [懶人包]現在的工作流程(以Win10機器為例) #### 安裝篇 1. 安裝 Rmarkdown 1. 安裝 R:網址為 https://www.r-project.org/ 2. 安裝 RStudio:網址為 https://www.rstudio.com/ 3. 安裝 rmarkdown、devtools 套件: - 在 R 中安奘 rmarkdown ```R install.packages("rmarkdown") ``` - 在 R 使用 devtools 套件至 GitHub 更新 rmarkdown ```R install.packages("devtools") #如果以前沒有安裝 devtools devtools::install_github("rstudio/rmarkdown") ``` 4. 安裝 rticles:在 R 中執行 ```R devtools::install_github("rstudio/rticles") ``` 2. 安裝 $\LaTeX$ 環境 1. 安裝 MiKTeX:請使用 64-bit Net Installer 先下載完整包裝再安裝(很大,約 2GB 左右),網址:http://miktex.org/ 2. 安裝 Texmaker:非必要,只是順便,網址:http://www.xm1math.net/texmaker/ 3. 安裝 Pandoc:用來轉換 Markdown 至 \LaTeX ,網址:http://pandoc.org/ 3. 設定 RStudio 1. 開啟 RStudio 。 2. Tools -> Global options -> Sweave - Weave Rnw file using: **Knitr** - Typeset LaTex into PDF using: **XeLaTex**(才能支援 UTF-8 中文) 4. 在 R 中安裝 SASmarkdown (為了SAS作業) ```R install.packages("SASmarkdown") ``` 5. 安裝 VS Code(修文字檔好用)、[typora](https://typora.io/)(類Word Markdown編輯器) 6. 製作 rmarkdown 用的 $\LaTeX$ 預載設定檔(存成 `.tex`) 目前我用的如下: ```LaTeX= % Set CJK \usepackage{fontspec} \usepackage{xeCJK} \setCJKmainfont{標楷體} %設定中文為系統上的字型,而英文不去更動,使用原TeX字型 \XeTeXlinebreaklocale "zh" \XeTeXlinebreakskip = 0pt plus 1pt %這兩行一定要加,中文才能自動換行 % SAS \usepackage{statrep} ``` 要指定載入這些檔頭,需在 rmarkdown 的檔頭 yaml(用兩行 `---` 隔出來的區域) 中的 `output: pdf_document:`中加入(從第3行開始): ```yaml= output: pdf_document: includes: in_header: 檔案路徑/檔案名稱.tex ``` (同資料夾下可省略 `檔案路徑/`) #### 作業篇 不需要程式的文件 1. 文本先用 typora 打草稿 (有時直接省略) 2. 用 typora 匯出成 `.tex` 檔 3. 用 Texmaker 開 .tex 調整版型輸出 PDF 需要程式的文件 1. 程式碼先用 VS Code 打草稿 (有時直接省略) 2. 程式碼以 RStudio 或 SAS 執行確認成果 3. 文本用 typora 打草稿 (有時直接省略) 4. 以 RStudio 將草稿與程式碼以 rmarkdown 整合 5. 設定輸出保留 .tex 檔,輸出觀察 PDF,如需調整版型用 Texmaker 開 .tex 調整,輸出 PDF #### 一些小撇步 1. 你可以在供 Pandoc 轉換的 markdown 裡面使用 $\LaTeX$ 或 html 指令:大致上都會直接在轉碼上保留 2. markdown 給的表格語法不堪使用,$\LaTeX$ 難以閱讀管理,這時請愛用 http://www.tablesgenerator.com/ 3. 習慣用英文搜尋你的排版問題,因為多數的解答都是英文 最後,這篇文章用 typora 打草稿並上傳至 HackMD,要看 markdown 原始碼的可以點開看 [^1]: 排版:置中、斜體、項目符號等等你在 Word 裡面按按鈕調整外觀的東西etc. 詳情可參見[維基百科](https://zh.wikipedia.org/wiki/%E6%8E%92%E7%89%88) [^2]: 編輯器(editor):指的是以程式碼編輯為核心功能的純文字檔編輯器,相較於 IDE 比較單純

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully