Department of Sociology, CUNY Queens College, New York, NY

Using Markdown in PyCharm

Starting your Markdown document in PyCharm

Markdown is a coding language that allows users to prepare their code and write-up in the same document. Computer code and narrative explanations are prepared simultaneously. This operation is performed on PyCharm.

Getting Started

To get started, install the Jupyter package in your PyCharm IDE:

  • In the bottom right, click the interpreter (where the version of Python is listed), then Interpreter Settings
  • In the Settings window that pops up, navigate Project > Python Interpreter
  • In the main part of the Settings window, click the plus sign (+) listed above the list of installed packages
  • In the search bar, enter “Jupyter”, select the jupyter package, and click “Install Packages”

Create a Markdown File in a Jupyter Notebook

  • Go to File > New > Jupyter Notebook.
  • Name your notebook and it will open in a new tab.
  • Jupyter Notebooks are divided into cells. Each cell can contain Python, Markdown or other code. To designate the cell as programmed in Markdown, right-click the cell and choose “Convert Cell to Markdown.” That cell can now contain Markdown.
  • Write whatever text you choose in the Markdown cell. When you are done, press Shift + Enter to execute it.
  • Run cells individually with Shift + Enter or run all cells with the Run button.
  • Output from code cells (e.g., print statements, plots) will be displayed immediately below the cell.

Markdown Code

Syntax Result
# Header 1 Header 1
## Header 2 Header 2
### Header 3 Header 3
**bold text** bold text
*italicized text* italicized text
~~strikethrough~~ strikethrough
[Google](https://google.com) Google
![image](src) image
> blockquote
blockquote
- list item 1
- list item 2
- list item 3
  • list item 1
  • list item 2
  • list item 3
1. numbered item 1
2. numbered item 2
3. numbered item 3
  1. numbered item 1
  2. numbered item 2
  3. numbered item 3
code block
**Bold** and *italic* combined Bold and italic combined
---
<dl><dt>Term</dt><dd>Definition</dd></dl>
Term
Definition
[1]
[1]: Footnote text.
[1]
Footnote text.
<mark>highlighted text</mark> highlighted text

Programming in Cells

Instead of text, one can also insert Python code into a Jupytr notebook cell. You can code:

  • line-by-line, using the hotkey: SHIFT + ENTER
  • the cell alone, using the hotkey: CTRL + ENTER
  • the entire script, using the hotkey: SHIFT + CNTRL + ENTER

Export to Word

In the terminal, export the file to HTML:

Then open that HTML file in Word.

Saving

Save your notebook regularly. Jupyter notebooks are saved with a .ipynb extension. It contains both your narrative report and code, and is useful for sharing with fellow analysts.

Additional Notes

  • Document Your Process: Use Markdown cells to document your thought process, allowing you to trace and fix your lines of reasoning and workflow.
  • Version Control: PyCharm offers integrated Git support, allowing you to version control your notebooks. Version control allows you to roll back time, for those moments when you’ve wrecked everything or need to know if you did something different in earlier analyses.

Leave a Reply

Your email address will not be published. Required fields are marked *