Centering Text in IPython notebook markdown/heading cells?

前端 未结 4 2070
耶瑟儿~
耶瑟儿~ 2021-02-05 01:28

I want to customize my notebook, make it more readable and stylish. So for that, I want to start with centering my headers. Is it possible?

相关标签:
4条回答
  • 2021-02-05 01:34

    It's quite simple to make your text stylish in Jupyter-notebook as it's syntax are similar to HTML.

    For example, you can use the following commands to play with your texts:

    1.**bold_text** will make your test bold like bold_text.
    2.*italic_text* will result in italic text like italic_text
    3.***bold_italic_text*** will result in bold and italic text like bold_italic_text
    4. You can use <h1> header1 </h1> to make the text as header like

    header1

    You can replace h1 within the angular brackets with any number h2,h3 etc. to get header of different sizes.
    5. For text alignment you can use Centered_text to align you text to the center.
    6. Use <br> to breakline or if you want the following text to be printed in next line.

    These are just basic things, you can do many more things.

    0 讨论(0)
  • 2021-02-05 01:43

    Not directly with markdown i think, but you can just enter HTML in the markdown cells:

    <h3 align="center">This is a centered header</h3> 
    
    0 讨论(0)
  • 2021-02-05 01:44

    Knowing that in jupyter (ipython) notebook markdown cells the title level is identified by the number of # (# for top level headings or h1, ## for h2, ....), I use the following combination of HTML and markdown:

    # <center>Your centered level h1 title</center>

    ## <center>Your centered level h2 title</center>

    etc..

    It's straightforward and the easiest to remember but please do comment if there's any disadvantage in doing so.

    Tested in jupyter version 4.4.0 (not sure about other version but no reason it doesn't work).

    0 讨论(0)
  • 2021-02-05 01:45

    You can actually use the markdown mode for the cell and use the normal HTML code, as in

    <h1><center>Centered text!</center></h1>
    
    0 讨论(0)
提交回复
热议问题