I am fairly new to python and have no html experience. The question has been asked and either not answered at all or not answered in enough detail for me to set the default font within iPython (not change to browser). Specifically, what has to be put in the css file and which css file should be used? I am on a Windows system.
For reference, these are in answer to the linked SO questions below:
in #1: an unnamed file in /usr/lib/python2.6/.../css/
in comment to #1: change monospace font in browser - worked but font is italic
in #2: custom.css in profile subdirectory /static/custom/custom.css
Related questions:
Change ipython notebook font type
Change font & background color in ipython notebook
Changing (back to default) font in ipython notebook (unanswered) -
Edit:
Changing the monospace font in my browser worked, as suggested in an answer comment of #1. However the font is italic, which is not what is intended.
You can hover to .ipython folder (i.e. you can type $ ipython locate in your terminal/bash OR CMD.exe Prompt from your Anaconda Navigator to see where is your ipython is located)
Then, in .ipython, you will see profile_default directory which is the default one. This directory will have static/custom/custom.css file located.
You can now apply change to this custom.css file. There are a lot of styles in the custom.css file that you can use or search for. For example, you can see this link (which is my own customize custom.css file)
Basically, this custom.css file apply changes to your browser. You can use inspect elements in your ipython notebook to see which elements you want to change. Then, you can changes to the custom.css file. For example, you can add these chunk to change font in .CodeMirror pre to type Monaco
.CodeMirror pre {font-family: Monaco; font-size: 9pt;}
Note that now for Jupyter notebook version >= 4.1, the custom css file is moved to ~/.jupyter/custom/custom.css instead.
In JupyterNotebook cell,
Simply you can use:
%%html
<style type='text/css'>
.CodeMirror{
font-size: 17px;
</style>
I would also suggest that you explore the options offered by the jupyter themer. For more modest interface changes you may be satisfied with running the syntax:
jupyter-themer [-c COLOR, --color COLOR]
[-l LAYOUT, --layout LAYOUT]
[-t TYPOGRAPHY, --typography TYPOGRAPHY]
where the options offered by themer would provide you with a less onerous way of making some changes in to the look of Jupyter Notebook. Naturally, you may still to prefer edit the .css files if the changes you want to apply are elaborate.
The new location of the theme file is: ~/.jupyter/custom/custom.css
In your notebook (simple approach). Add new cell with following code
%%html
<style type='text/css'>
.CodeMirror{
font-size: 12px;
}
div.output_area pre {
font-size: 12px;
}
</style>
Using Jupyterthemes, one can easily change look of notebook.
pip install jupyterthemes
jt -fs 15
By default code font size is set to 11 . Trying above will change font size. It can be reset using.
jt -r
This will reset all jupyter theme changes to default.
In addition to the suggestion by Konrad here, I'd like to suggest jupyter themes, which seems to have more options, such as line-height, font size, cell width etc.
Command line usage:
jt [-h] [-l] [-t THEME] [-f MONOFONT] [-fs MONOSIZE] [-nf NBFONT]
[-nfs NBFONTSIZE] [-tf TCFONT] [-tfs TCFONTSIZE] [-dfs DFFONTSIZE]
[-m MARGINS] [-cursw CURSORWIDTH] [-cursc CURSORCOLOR] [-vim]
[-cellw CELLWIDTH] [-lineh LINEHEIGHT] [-altp] [-P] [-T] [-N]
[-r] [-dfonts]
For chrome users, This is very simple.
Just install the desired font in your OS. Then open the said browser, Go to
Settings -> Appearance -> Customize font.
Go to fixed width font and from drop down list select the desired font.
Note: This might also change the fonts at some other places depending on the web pages that you visit.
There is a much easier way to do without adding the CSS files and all the other methods suggested. But you have to do it every time you start the Jupiter notebook.
Go to inspect in your browser and click on the element selection icon and then click on the box.
And at the bottom of the page, you will be seeing the styling option for CSS where you can easily change the font-size.
Related
When passing style argument along with a <span> starting block, I changed font-size and font-family and all of that in my Jupyter notebook's individual cells. Like so-
<span style="font-family:Verdana">Irrelavant text.</span>
OR
# Model Building <span style="font-size:12px">[Jump to Beginning](#top)</span>
It was working just fine until about a week or so ago, when all of the style effects in my notebook just disappeared. The code is obviously still there in the markdown cells but it just doesn't show the intended result. The same notebook still works and loads the style when ran on Kaggle or JupyterLab. Did Jupyter notebooks stop supporting it or did I change something unintentionally? What could be a workaround or maybe even a fix for the issue without changing the code?
It used to look like this (avoid the black theme, screenshot is from JupyterLab)-
And now it looks like this-
As you can see, the font-size:12px has no effect anymore. Same goes for font-family and the likes.
Edit: Notebook
Inline styles in Markdown cells were temporarily removed in a security fix addressing a different sanitization issue earlier last month and restored in just released v6.4.4. Please update your notebook installation for the old styling in Markdown to work again.
JupyterLab 3.2.2, 3.2.3 and 3.2.4 are also affected by a similar issue. It was already fixed in PR #11510 and the fix was released in JupyterLab v3.2.5 on 10th December 2021.
I don't think this is the answer you wanted, but it works. It is scalable, too. I usually use Python with Atom, XCode, or RMarkdown in RStudio, so I am not all that familiar with the ins and outs of Jupyter's interface.
First, I noticed that I could see the text rendered as expected when I went to print preview. However, I thought that that was pretty useless. What are you going to do? Go to print preview every time you write something? What's the purpose of an interactive notebook at that point?
I digress.
Okay, so what I found that worked... in no way is this an idea that is originally mine...
Custom CSS
Adding a custom CSS file, but not the 'change it all' thing that the Jupyter help files suggest...
Step 1)
Create a styles folder in the same directory as the ipynb file.
Step 2)
Within the styles folder, create a CSS file.
Step 3)
Within that CSS file, write the two tag styles and any others you desire.
Here's that code (pictures of code are annoying).
div.verdana {
font-family:verdana;
}
div.bigger {
font-size: 20pt;
}
Within the ipynb File
Step 4)
Next, add the div tags to your ipynb file in a Markdown cell:
<div class='verdana'>This should be Verdana font.</div>
The result after running the cell:
Step 5)
Do the same thing with the bigger font.
You highlighted the desire for font-size:20px; I inadvertently did font-size:20pt. Just change the pt to px.
Add the div tags to your ipynb file in a Markdown cell:
<div class="bigger">Font size 20px</div>
The result after running the cell:
Step 6)
Somewhere in the notebook, you need to call the link to the CSS file. I just added it to the end:
from IPython.core.display import HTML
def css_styling():
styles = open("./styles/custom.css", "r").read()
return HTML(styles)
css_styling()
It can go at the end because the entire kernel executes initially (so it doesn't need to be before you call the tags.
FYI
I did try to use magic, but it did not work for the font-family:
%%html
<style>
// add your CSS styling here
div.verdana {
font-family:verdana;
}
div.bigger {
font-size: 20pt;
}
</style>
I use Sphinx with the Read the Docs theme. For small inline code snippets, such as the mention of a single variable among a piece of text, I use double backticks to format the code as what's called "inline literals" in the documentation.
Is this the proper way to format inline code snippets?
Unlike proper code blocks, no language specific syntax highlighting is performed on the inline code snippets (that's fine). As seen in the linked documentation above (see the below screen shot), all such "inline literals" are colored red.
How can I change this color to something else?
I'm only concerned with the HTML output of Sphinx.
I found a solution, though it involves changing the Sphinx RTD theme source code.
The HTML coloring used by the RTD theme is specified in sphinx_rtd_theme/static/css/theme.css, with the sphinx_rtd_theme directory located in the site-packages directory of the Python installation. The red color used is #e74c3c and the specific place which sets this color for inline literals is
literal{color:#e74c3c}
Changing this color does exactly what I want. Making changes directly to theme_css feels wrong though. The specific change takes place on line 4, which is over 100000 characters wide! Clearly this file is generated from other files. I guess the proper solution involves performing the change do one of these (to me unknown) files.
Edit: Proper solution
With a custom .css file, the colors of the inline literals can be set using
code.literal {
color: #404040 !important;
background-color: #fbfbfb !important;
}
The name of a .css file containing the above should be added to html_css_files in the Sphinx conf.py, i.e.
# conf.py
html_css_files = ['custom.css']
It is very difficult to read the code due to very small font of octave editor. I am unable to find where to change this font setting for editor text.
I am attaching the screenshot of the octave editor platform.
I expect to increase my editor font to work properly.Thanks
You can change the entire Ubuntu font by
gsettings set org.gnome.desktop.interface text-scaling-factor [font size ]
Example :
gsettings set org.gnome.desktop.interface text-scaling-factor 1.4
to know about current font use following command
gsettings set org.gnome.desktop.interface text-scaling-factor
I use the asciidoctor-maven-plugin(1.5.3) to convert asciidoc files to pdf and html files.
Problem:
The pdf file that is created is rendered including the admonition icons - So, all is well here.
The html file on the other hand does not seem to be created in the right way - the admonition icons are missing. There is no text/caption instead just a strange placeholder.
I tried using the :icons: font backend attribute, where font is the only option I found in the asciidoc documentation.
(By the way this is the same as adding <icons>font</icons> like shown below in the pom.xml.)
The font option should show icons from http://fortawesome.github.io/Font-Awesome/icons/ but it does not.
Question:
Do I have to import those icons form anywhere or dowload them and specifically include them using the :iconsdir: path/to/icons backend attribute?
The important part of the pom.xml looks like this.
<configuration>
<backend>html5</backend>
<sourceHighlighter>coderay</sourceHighlighter>
<attributes>
<imagesdir>./images</imagesdir>
<toc>left</toc>
<icons>font</icons>
<sectanchors>true</sectanchors>
<idprefix/>
<idseparator>-</idseparator>
</attributes>
</configuration>
Ok, this is embarrassing, at least one half of the story.
The embarrassing part
The actual mistake I made was using the noscript firefox plugin, which disallowed the use of fontawesome....
In fact, I had to explicitly allow cloudfare.com in noscript to make it work.
So, my pom.xml stays with the attribute <icons>font</icons>.
The good part
I found out how to use custom icons:
declare <iconsdir>./images/icons</iconsdir> (This is also the default, relative to the source directory.)
copy some icons in it. I got them from here. (Pay attention to the names: note.png for NOTE: This is a note.)
change <icons>font</icons> to <icons>image</icons>
Recently I installed this awesome HTML plugin, which matches closing tags, and it works really well. I was just wondering if it's possible to change highlighting color (I'm using Solarized colorscheme). Here's screenshot of how it looks now:
I think it's possible to change the color in solarized.vim file, but there's a lot of highlighting options. I would like to set it to some other color, that's more pleasant for the eye, as tags are barely seen because of low contrast.
The MatchTag plugin is using the related MatchParen highlight group (:help hl-MatchParen). You can relink that to any other group in your ~/.vimrc, for example:
:hi link MatchParen IncSearch
or define your own highlight attributes. Put the command after any :colorscheme command, though.