Centering Text in IPython notebook markdown/heading cells? - jupyter-notebook

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?

You can actually use the markdown mode for the cell and use the normal HTML code, as in
<h1><center>Centered text!</center></h1>

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>

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).

the easy way for me is just :
# <center> some fancy title here
it works without closing the tag, so i usually copy "<center>" and past it away in a single step when i finish.

You can use one of the following lines - text cell.
<center>Your centered level h1 title</center>
<center> some fance title here
from Markdown_Guideline

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.

if you want to make a header you can easily use # at the beginning of text to make it big size and also bold, ## will also do the same but text size will be smaller, you can reduce the size of the bold text by increasing the #s up to 6.

Related

Can I add a css style in the formula editor in crystal report

In crystal report:
right click on a field -> edit formula. I can add some html elements.
example
<u>
IF {myobject.myfield} = "something" THEN
blabla1
ELSE
blabla2
</u>
Is there a way to add a css font style?
I would like to underline the whole line. Not only where there is text
You can use something like this:
IF {myobject.myfield} = "something" THEN
<u>blabla1</u>
ELSE
</u>blabla2</u>
But that would require turning on the 'Interpret as HTML option.
Why not simply format the formula object with underline?
Even with a CSS style, it will still only underline the text and will not extend the underline beyond.
I see two other ways to accomplish this though.
Make the field the entire width of the area that you want to be underlined, then add a bottom border to the field or text object.
Use the line drawing tool to add a horizontal line to the report where it is needed.
It doesn't give a solution to the mentioned problem. But it give a solution to the problem that leads to this problem, i.e., underline the whole line.
select the feld, click on underline. In "edit formula", add space(N) before each line break. With N is a big number

Costum dynamic pandoc (or Latex) command to set text color

I prepare a document in Markdown in which I have to highlight changes in color. I am aware that I could wrap the text like this:
This text is unchanged, however \textcolor{red}{I changed this}, before going back to the original color.
But I would prefer to define my own command, similar to the **<this is bold text>** solution, without all the brackets. I found the following solution to make all bold text also blue, but since I am new to latex I have been unsuccessful trying to adapt this. I found out how to change the textcolor after a custom command for the rest of the document by including this at the beginning of my Markdown document:
\newcommand{\x}{\color{red}}
Like this, the text color switches to red after I write \x somewhere in the text. The next step would be along these lines:
\newcommand{\x}{%
\ifthenelse{\equal{\color}{black}}% if the text color is currently black
{\color{red}}% set it to red
{\color{black}% else set it back to black}}
I want this custom command to check the current text color. Like this, I could ideally have some unchanged text and \x wrap the changed section in the custom command, making this red \x, before going back to the original color.
Does anyone have an idea how I could write this in Latex? Any help appreciated!
Using a similar approach as in https://stackoverflow.com/a/52390056 , you could change the behaviour of **...** to give red text instead of bold:
\renewcommand\textbf[1]{\textcolor{red}{#1}}

SVG styling of text with NVD3 library

I have created a very simple chart with NVD3.js as can be seen on this fiddle.
The problem lies with the title (text in the middle) which consists of a number and a symbol (%).
I need both those parts to be styled separate but this seems to be a real pain.
I have discovered I can only style an SVG through inline style tags so I already applied :
<div id="svgDiv"><svg id="test2" fill='#58B957' letter-spacing='-3px'></svg></div>
to get the color and spacing right. Now I still need the %-symbol to be a lot smaller than the number. Which I can't apply to the full svg, because this would make everything smaller.
I have tried all manners of adding classes, id's, wrapping them in tspan's etc; yet I can't figure it out.
Please tell me there's a straightforward solution for this?
I dont think there is a direct way in nvd3 but you can do this trick to empty the text and fill with tspan.
var text1 = d3.select(".nv-pie-title").text("");//get the title clear it
text1.append("tspan").attr("class", "number").text("85")//make first tspan
text1.append("tspan").attr("class", "percent").text("%")//make second tspan
working code here

Respect space in code but ignore with CSS?

With CSS can I make a browser ignore the character but respect normal white space?
So this:
Some text More text
Is displayed like this:
Some text More text
Not:
Some text More text
UPDATE There is actually more white space in my code. I need the default behavior where extra white space doesn't get rendered on the page so I dont think I can use white-space: pre or pre-wrap
So this shouldn't be excessively indent before the initial word.
Some text More text
I don't think there's a pure CSS way of doing that, since is an actual character that is different from the whitespace created by the spacebar in a text editor (what gets ignored by HTML renderers). However, depending on how those are appearing, you may be able to use a script that searches for and removes that character wherever it sees it.

How to decide What should be chosen to make heading bold <strong> or <h3/h4/h5>?

How to judge what should be <h2> , h3 h4 h5 h6 or <p><strong>Some text</strong></p> If we don't have knowledge about context
Only title of the page i can judge easily <h1>
How to judge others I always get content from clients in MS word 2007 format and client always use fontsize to make things smaller and bigger.
How we can best judge where client want Headings level and where he used bold text only for styling and where He really want to give emphasize on text.
<p><strong>Some text here</strong></p>
<p>Some more text here Some more text hereSome more text here
Some more text hereSome more text here Some more text here
</p>
Or any heading level
<H*>Enquiries to:</h*>
<p>Some more text here Some more text hereSome more text here
Some more text hereSome more text here Some more text here
</p>
Which would be good for accessibility?
Heading are what their name suggests, they should be used for headings or titles. Heading make them bold as well as different sizes based on their level. For other piece of text, you have to decide whether you want to make it bold or not.
Also, heading tags are good for search-engine-optimization, the SEOs usually put the page titles or important keywords inside these heading tags.
If you simply want something to appear bold, use the <strong> tags instead.
What i would suggest you is:
You should use headings for the titles or important keywords for the SEO purpose and you should use the other bold type tags such as b or strong at your own will when you want to make something appear bold.
Example:
<H2>Amazing Laptops</h2>
<p>
We deal in great <strong>quality laptops</strong> you will ever come across.
</p>
Bottom Line:
There is a world of difference between bold type tags such as strong and heading tags. They serve the different purpose, you can not compare them.
If the "some text here" sums up the section(s) or paragraph(s) that come directly after it, then it can be considered a header. Otherwise, it's just another piece of text.
Another good rule of thumb is that headers should not contain colons. So:
<h1>Inquiries</h1>
<p>Please send your inquiries to blabla.</p>
But:
<p><strong>Send your inquiries to:</strong><br />
blabla</p>
I would say don't worry about the formatting to decide which heading to use, you can always adjust the look with CSS.
My rule of thumb is to think of what you would want to see in a well organized and hierarchical table of content. If you would want the text in it then use a H[123456] tag. Then the more prominent use closer to H1, less prominent use closer to H6. Use the same Hn for things that are at the same level of importance.
It does not matter if you don't have a TOC in the end, but that will help you think how to organize your headings.
Unfortunately there is no definitive formula for whether some piece of text should be a heading or not. If you don't understand what your client is looking for, I suggest you ask the client. We have even less idea since we haven't seen the data.
It's pretty common anymore to actually just use the header tags as placeholders really, and define adjust the design via CSS. Also
I think as far as you're question, you kind of just use them as they are in a hierarchical order based on what you can assume. Like you said page header would make sense to use <h1>, section header maybe <h2> and so on, and as adjustments need to be made just alter they're font size with CSS.
.content_area h1{font-size:18px;font-weight:bold;}
.content_area h2{font-size:14px;font-weight:bold;}
etc...

Resources