Paragraph FormattingParagraphs wrap content inside the body of a document or frame. They are the fundamental container for free flowing text in your documents. A paragraph inherits the properties of a Span formatter, and adds borders, tabs and indenting. View on YouTube
BlocksLet's review some basics. A Block contains Paragraph or Table elements. If those elements are not already Paragraphs, they will be automatically placed inside a Paragraph. A Block can have formatting properties, which will serve as the default properties of the child elements. SimpleBlock = Block { // Explicit paragraph Paragraph { "Paragraph One"; }; // Non-paragraph elements turned into a paragraphs "Paragraph Two"; Span {Bold; Math.Sqrt(2) + 1};};Paragraph OneParagraph Two2.414213562373095
Nested BlocksA Block can be included inside another Block, but this does not create a nested structure. Instead, the parent Block will simply include the child Block's formatted content. NestedBlock = Block { TextColor: Colors.Red; Block { "Line 1"; }; "Line 2"; Block { TextColor: Colors.Blue; "Line 3"; };};Line 1Line 2Line 3Default block formatOverridden format
ParagraphsA Paragraph is a formatter that puts its child elements end-to-end into horizontal lines. The text will wrap at the edge of the available space, and may continue onto the next page of the document. Success = Paragraph { "I've missed more than 9000 shots in my career. "; "I've lost almost 300 games. "; "26 times I've been trusted "; "to take the game winning shot and missed. "; "I've failed over and over and over again in my life. "; "And that is why I succeed. "; "–Michael Jordan";};I've missed more than 9000 shots in my career. I've lost almost 300 games. 26 times I've been trusted to take the game winning shot and missed. I've failed over and over and over again in my life. And that is why I succeed. –Michael Jordan
IndentingUse the LeftIndent, RightIndent, and FirstIndent properties to control the margins of the paragraph. Notice that you may revise an existing paragraph with new properties, without changing the original. Greatness = Paragraph { "Be not afraid of greatness. "; "Some are born great, "; "some achieve greatness, "; "and others have greatness thrust upon them. ";};Quote = Block { Greatness { RightIndent: 10pt; LeftIndent: 16pt; FirstIndent: -8pt; // Relative to LeftIndent TextHeight: 120%; }; Italic "― William Shakespeare, Twelfth Night";};Be not afraid of greatness. Some are born great, some achieve greatness, and others have greatness thrust upon them. ― William Shakespeare, Twelfth Night
AlignmentAlignment of the text can be controlled with the ParAlignment property. SmallBlock = Block { Paragraph {ParAlignment: Left; "Left"}; Paragraph {ParAlignment: Center; "Center"}; Paragraph {ParAlignment: Right; "Right"};};LeftCenterRight
Justify AlignmentThe Justify alignment stretches the spaces in the line so that it fits evenly on the right. JustifiedBlock = Paragraph { ParAlignment: Justify; "As the light changed from red to green to yellow and back to red again, "; "I sat there thinking about life. "; "Was it nothing more than a bunch of honking and yelling? "; "Sometimes it seemed that way. "; Tex.EmDash; " Jack Handey";};As the light changed from red to green to yellow and back to red again, I sat there thinking about life. Was it nothing more than a bunch of honking and yelling? Sometimes it seemed that way. — Jack Handey
Tab stopsThe tabstops argument is an array of TabStop objects that determine how the tab character is interpreted inside a paragraph. TabStop[] TabList = [ 5%, // Left align (default) new(20%, TabTypes.Bar), // Place vertical bar (no stop) new(30%, TabTypes.Center), // Center text around tab new(60%, TabTypes.Decimal), // Line up decimal point at tab new(95%, TabTypes.Right, TabLeaders.Dot), // Right align at tab];TabStopExample = Block { Paragraph(null, TabList) { Tab; "Left"; Tab; "Center"; Tab; "3.1415"; Tab; "Right"; }; Paragraph(null, TabList) { Tab; "Left Align"; Tab; "Center Align"; Tab; "527.10"; Tab; "Right Align"; };};LeftCenter3.1415.....................................................RightLeft AlignCenter Align527.10.................................................Right Align
FramesA Frame is a rectangular box that can contain Paragraphs and Tables, but it acts like a large character when placed inside a Paragraph. FrameExample = Paragraph { "Quote "; // Acts like a big single character Frame(30%, null, new Edge(1, 4pt)) { "Luck is what happens when preparation meets opportunity."; "—Seneca "; }; " of the day. ";};Quote Luck is what happens when preparation meets opportunity.—Seneca of the day. Large 'character' in the text
Inline listsA ListSpan formatter can be used to create a numbered list inside a paragraph with a variety of numbering styles. Notice that the "Topics" array variable is automatically expanded inside the revision to become a part of the numbered list. Topics = ["Point one", "Point two", "Point three"];NumberedSpan = Paragraph { "Main discussion points: "; ListSpan(@Enumerators.NumberParens) { Separator: "; "; End: DotSpace; Topics; };};Main discussion points: (1) Point one; (2) Point two; (3) Point three.
Background ColorParagraphs have an optional background color which can be set with the ParBackground property. HeaderPar = Paragraph { ParBackground: Colors.Blue; TextColor: Colors.White; ParAlignment: Center; Bold; "Header";};Header
Space BeforeAdd extra space before the start of a paragraph using the SpaceBefore property. ParSpaceBefore = Block { Bold "Header"; Paragraph { "First line"; SpaceBefore: 200%; };};HeaderFirst lineSpace before the paragraph
Space AfterAdd extra space after the end of a paragraph using the SpaceAfter property. ParSpaceAfter = Block { Paragraph { SpaceAfter: 200%; TextHeight: 120%; Bold; "Title"; }; "Body text";};TitleBody textSpace after the paragraph
BordersSet the border argument for a Paragraph to display a border on any combination of sides. BorderPar(Border border) = Paragraph(border) { ParAlignment: Center; ParBackground: 95%;};BorderExamples = Block { Separator: Paragraph; BorderPar(4pt) {"all sides"}; BorderPar(BorderTB(4pt)) {"top - bottom"}; BorderPar(BorderLR(4pt)) {"left - right"};};all sidestop - bottomleft - right
Border color and paddingParagraph borders can also have different colors and paddingColorBorder = Paragraph(new Edge(3pt, 5pt, Colors.Red)) { ParAlignment: Center; ParBackground: #FCFCF4#; LeftIndent: 16pt; RightIndent: 15pt; Bold; "Very Important Notice";};Very Important Notice
Line HeightChange the default line height using the LineHeight property. LegalText = Block { LineHeight: 200%; TextFace: Mono; Paragraph { Bold; TextCase: AllUpper; Underline; "Memorandum of Points"; }; "Statement of Relevant Facts";};MEMORANDUM OF POINTSStatement of Relevant FactsDouble-spaced lines
Create Named StylesUse global variables to create styles with familiar names. You can even use a named style to serve as the root template for another style, as show below. Normal = Paragraph {TextFamily: TextFamilies.CMUSerif};Heading1 = Normal {ParAlignment: Center; TextFace: Serif; TextHeight: 140%; Bold};Heading2 = Normal {TextHeight: 110%; Underline};Body = Normal {FirstIndent: 8pt; TextFamily: ParAlignment: Justify};Chapter1 = Block { Heading1 {"Chapter 1"}; Heading2 {"Introduction"}; Body {"Consider the curious case of Dr. Jeckle. "};};Chapter 1IntroductionConsider the curious case of Dr. Jeckle.
Style SheetsOnce you have a set of styles, you can use them consistently throughout your content. Now, all of your style information is in one place, separated from your content. Emphasis = Span {Italic; TextColor: Colors.Red};Chapter2 = Block { Heading1 {"Chapter 2"}; Heading2 {"Introduction"}; Body {"I would like to "; Emphasis {"emphasize"}; " the following points. "};};Chapter 2IntroductionI would like to emphasize the following points.
Combine ContentYou can also build manageable blocks of content in the same way, for reuse in different documents, limited only by your imagination. A global style change, across all content and all documents is now almost instant. Book = Block { Chapter1; Chapter2;};Chapter 1IntroductionConsider the curious case of Dr. Jeckle. Chapter 2IntroductionI would like to emphasize the following points.