# New Formatting Options

We've rolled out some improvements to our formatting engine today, and wanted to let everyone know how to take advantage of them.

For a full specification of formatting on Brilliant, you can review the full formatting guide.

The two new things you'll probably want to know about:

## Tables

It is now possible to use tables in problems and notes on Brilliant.

This code:

 1 2 || 1 || 2 || 3 || 4 || || a || b || c || d || 

produces this:

 1 2 3 4 a b c d

## Code Snippets with Syntax Highlighting

There is also a new method for code blocks. Previously, it was necessary to use four spaces before any line of code, like this:

Type this:

 1 2 3  print "Hello World!" for x in range(5): print x 

Get this:

 1 2 3 print "Hello World!" for x in range(5): print x 

However, we have a new method, which produces the same output and is easier to work with. Now you may simple add three backticks (  ) on the lines before and after your code, and you'll get the same result:

Type this:


print "Hello World!"
for x in range(5):
print x



Get this:

 1 2 3 print "Hello World!" for x in range(5): print x 

In addition, the new system allows syntax highlighting for C, Python, and Java code (and many others). Just add the language name in lowercase (c++ or cpp instead of C++ and javascript instead of JavaScript) after the first line of backticks.

Type this:

python
#A comment
print "Hello World!"
for x in range(5):
print x



Get this:

 1 2 3 4 #A comment print "Hello World!" for x in range(5): print x 

We're excited about these improvements and hope they'll be helpful to you.

Note by Arron Kau
6 years, 8 months ago

This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.

When posting on Brilliant:

• Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
• Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
• Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold
- bulleted- list
• bulleted
• list
1. numbered2. list
1. numbered
2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in $$ ... $$ or $ ... $ to ensure proper formatting.
2 \times 3 $2 \times 3$
2^{34} $2^{34}$
a_{i-1} $a_{i-1}$
\frac{2}{3} $\frac{2}{3}$
\sqrt{2} $\sqrt{2}$
\sum_{i=1}^3 $\sum_{i=1}^3$
\sin \theta $\sin \theta$
\boxed{123} $\boxed{123}$

Sort by:

 1 2 3 4 5 6 #include using namespace std; int main(){ cout<<"testing"<

- 2 years, 10 months ago

 1 2 3 4 5 #include using namespace std; int main(){ cout<<"testingsss"<

- 2 years, 10 months ago

 C++

# include<iostream>

int main(){ std::cout<<"testing2"<<endl; return 0; } 

- 2 years, 10 months ago

 1 std::cout<<"Thanks!\n"; 

- 5 years, 4 months ago

:-)

Staff - 5 years, 4 months ago

cool..

- 6 years, 7 months ago

 1 2 char * str = "This is awesome"; printf("%s",str); 

- 6 years, 7 months ago

How to use the LaTex code has been addressed, too? I read many answers not appearing as examples in the formatting guide, such as this one

\sqrt{2}

- 6 years, 7 months ago

There is one problem-

When I use this code

def doNothing():
'''
It does nothing.
'''
pass


I got this

 1 2 3 4 5 def doNothing(): ''' It does nothing. ''' pass 

Notice, the third line 'It does nothing.' doesn't have four spaces before it as I wanted. It's not that a big problem but it would enhance readability if you could solve it.

- 6 years, 7 months ago

Great update! Keep up the good work and thank you very much, Brilliant.

Can you add IDE (in example: Sphere Engine) into the Computer Science section?

 1 2 3 4 5 6 7 8 #include using namespace std; int main() { cout << "Thank you very much, Brilliant!"; return 0; } 

- 6 years, 8 months ago

That is interesting, we will consider that but it probably would not be a high priority feature, we may add a link to http://ideone.com/ for people to use (sorta like we have a link to the Daum Equation Editor from our formatting guide (for users who use the chrome browser since it's a chrome plugin) even though we don't have immediate plans to add any kind of "easy $\LaTeX$ editor" to Brilliant.)

Also: the syntax highlighting code for C++ is c++ (or cpp) (I've edited your comment so that your code will be properly highlighted). Basically, all of the "codes" are the name of the language in lower case.

Staff - 6 years, 8 months ago

thanks, but I hope the experience will be like CodeForces or any other similar website

- 6 years, 8 months ago

 1 2 3 print "agreed" for x = 5: print x 

- 6 years, 8 months ago

 1 2 3 4 #A comment printf("Test Code C\n"); int ngmq = 0x3fff; return ngmq; 

- 6 years, 8 months ago

 1 2 #testing A comment 1y 9m later chr(int("3fff",16)) #gtranslate=>googling=>ended up reading cake recipes 

- 4 years, 10 months ago

 1 2 3 4 #m comment print " great ! " + " glad ! " for x in range(5) : print x 

- 6 years, 8 months ago

Hi, I fixed your comment, you were using normal single quotation marks ' instead of "backticks" which are under the escape key on most keyboards (you may have encountered the tilde ~ more often).

Staff - 6 years, 8 months ago

Cool! Let's see:

 1 2 3 4 a b c d

Being proficient with ${\LaTeX}$, let's see how that compares with a LaTeX table:

$\begin{array}{|cccc|}\hline 1&2&3&4 \\\hline \text{a} & \text{b} & \text{c} & \text{d}\\\hline \end{array}$

What do you guys think?

- 6 years, 8 months ago

We wanted to offer an easy alternative for those who do not know latex. Typing a bunch of || is much easier than memorizing the array / align environments.

Staff - 6 years, 8 months ago

Also, since we render $\LaTeX$ on our servers rather than in the browser and display it as an image most of the time, if you have a large table, it'll end up being a lot slower to display/more annoying to work with on some people's computers/internet connections.

Staff - 6 years, 8 months ago

since this post is 6 years old, i assume this information is outdated.
or is Latex still displayed as an image?

- 1 month ago

I don't think it is outdated, but you can ask staff :)

- 1 month ago

ty. i just wanted to make sure. if Latex would still be converted to images, i could just post images instead of Latex to speed up the loading. but i dont experience loading delays - only when i load daily problems, it sometimes takes a while until all the solutions are loaded, but i assume that has other reasons.

- 1 month ago

i thought i did. or is sam solomon not staff?
i think it is outdated because i can copy posted Latex text letter by letter.
i assume if it were a pic, i would not be able to do this.

- 1 month ago

Yes, now the table doesn't appear as an image, but not as text either, as you can't copy /paste the table, only the content inside.

- 1 month ago

@Percy Jackson @num IC

Yeah, we updated how $\LaTeX$ is rendered and now render it into code that browsers can understand rather than images on our servers. This means it should be faster for everyone to load even $\LaTeX$ blocks that take up a lot of screen space.

Staff - 1 month ago

Thank you :)

- 1 month ago

ty for this clarification and for increasing the performance. this makes it much easier.

- 1 month ago

PSA: It took me a minute to figure this out, a backtick on your keyboard is the key under the escape key. It is the unshifted version of the ~.

 1 print "Thanks for the update, Brilliant! " + "I'm sure it's going to be very useful!" 

- 6 years, 8 months ago

I think I've done too many code reviews, haha, this is a compulsive comment saying that:

1. It'll end up smooshing the two sentences together ("...Brilliant!I'm sure...")
2. String concatenation in python is inefficient (and some people's opinion ugly/un-pythonic) and the preferable way to print that would be:
 1 print "Thanks for the update, Brilliant!", "I'm sure it's going to be very useful!" 

Which also happens to add a space implicitly.

Staff - 6 years, 8 months ago

Hm, I didn't know that about the comma. I'll use that in the future. I tend to just use spaces at the end of parts of a concatenation.

- 6 years, 8 months ago

Oh, another cool thing, is that you can put any number of arguments and it converts them all to strings separately, so you don't have to do anything ugly like:

 1 print "I have " + str(num_cats) + " cats and " + str(num_dogs) + " dogs." 

 1 print "I have", num_cats, "cats and", num_dogs, "dogs." 

Staff - 6 years, 8 months ago

Maybe I shouldn't make this question here, but could you give me a simple explanation about how this is possible? How is print defined so that it can take n arguments*? Is it written in another language (not Python)?

• I know that obviously there is a limit for this, but it seems to be pretty big.

- 6 years, 5 months ago

I'm not sure what the process is for turning a function into a command (as in print "something" rather than print("something")) but for the function this is how I would implement it roughly (Note that I didn't actually look up what it takes to print to the stdout at a lower level, I'm just guessing it's something like sys.print):

 1 2 def print(*args): sys.print(u" ".join(unicode(arg) for arg in args)) 

*args grabs all arguments that aren't accounted for and puts them into a list for you to use in the function.

**kwargs` does the same for extra keyword arguments.

Staff - 6 years, 5 months ago

that's very helpful what does sys.print is it equivalent to normal print function do is it a part of python code? LOL I love how we are asking questions in here and I asked this even though this is 5 to 6 years old

- 5 months, 1 week ago