The requirements:
- Height of pages in the document should not be constrained by constant length (although page width should be).
- Every line in a paragraph should be indented more than the previous line of that paragraph (by constant length), with first line of each paragraph having no indent at all (indent of each successive line is incremented by constant length).
OUTPUT APPROXIMATION:
1 2 3
123456789012345678901234567890 <<< PARAGRAPH WIDTH
This is sentence 1. This is
sentence 2. This is sentence
3. This is sentence 4.\par
This is sentence 1. This is
sentence 2. This is sentence
3. This is sentence 4.
- Picture placed inside of such paragraph below any line of the paragraph should be indented as if it (the picture) were the next line. However, a picture following another picture in the paragraph should be indented exactly as that picture (which it follows). First line that follows a picture in the paragraph should have same indent as that picture.
OUTPUT APPROXIMATION:
1 2 3
123456789012345678901234567890 <<< PARAGRAPH WIDTH
This is sentence 1. This is
sentence 2. This is sentence
3. This is sentence 4.
| O O |
|\ ^ /| <<< PICTURE (INDENTED AS A LINE OF PARAGRAPH)
| --- |
_____
/O ^ O\
| --- | <<< PICTURE (SAME INDENT AS PREVIOUS PICTURE)
\_____/
This is sentence 5. This
is sentence 6.
- Lists placed inside of paragraphs described above should have their items themselves behave like those paragraphs with exception that the first line of an item instead of starting at no indent (like first line of a paragraph does) should start at greater indent than the line preceding the item (unless that line belongs to another item of same list, in which case both items are indented the same).
OUTPUT APPROXIMATION:
1 2 3
123456789012345678901234567890 <<< PARAGRAPH WIDTH
This is sentence 1. This is
sentence 2. This is sentence
3. This is sentence 4:
1. This is item 1. This <<< LIST LABEL IS INDENTED AS
is still item 1. A LINE OF PARAGRAPH
Item 1 again. POST-LABEL LINE-INDENTS BEHAVE
2. This is item 2. This AS USUAL BUT WITH
| is still item 2: LABEL WIDTH ADDED TO EACH
| a) This is item <<< SUB-ITEM AFTER ITEM LINE BEHAVES
| "a". Still AS IF IT WERE ITEM AFTER
| item "a". PARAGRAPH LINE
| b) This is item
| "b".
This is sentence 5. This
is sentence 6.
- Optional borders should be available around each paragraph, list item, or picture (allowing for paragraphs, list items, and pictures to be separated by horizontal lines, as well as allowing for equations contained within pictures to start with a wide vertical line).
- Vertical spacing between paragraphs, between paragraphs and pictures, or between pictures should be equal to interline spacing of a paragraph (should be constant throughout the document, with one exception below).
- If one paragraph or picture (solely containing equation or text) is completely (or almost completely) comprised of larger or smaller font size than the previous paragraph or picture, then vertical spacing between them should be split: such that one half of vertical spacing depends on font size of upper paragraph or picture and is contained within it (within frame of that paragraph or picture) while another half of vertical spacing (likewise) depends on font size of lower paragraph or picture and is (likewise) contained within it (each half of such mixed vertical spacing should be contained within its respective paragraph or picture, such that vertical space of larger font remains within confines of a structure where the text of that font is and likewise for smaller font).
OUTPUT APPROXIMATION:
large font size (20pt) <<< PARAGRAPH 1
| <<< LARGE FONT-SIZE INTERLINE-SPACING
---------------------- <<< END OF PARAGRAPH-1 FRAME
---------------------- <<< START OF PARAGRAPH-2 FRAME
| <<< NORMAL FONT-SIZE INTERLINE-SPACING
normal font size (10pt) <<< PARAGRAPH 2
Let's start with a code sample. It has several problems: (1) it's hard to position the border of math-equation node immediately after the border of preceding paragraph-line (or position it interline-space distance away from that line), (2) border of math-equation node overlaps with right-side bound of the page if 25mm (paragraph last-line's remaining length available after indent of 15mm) is specified (so I have no idea what to add to or subtract from 25mm to make the border of the math-equation node touch without overlap the border of the page), (3) border of math-equation node overlaps with bottom-side bound of the page too.
\documentclass[tikz]{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\path node[inner sep=0,draw,text width=40mm,anchor=north west]
{ \parbox{\hsize}
{ \parshape 4 0mm 40mm 5mm 35mm 10mm 30mm 15mm 25mm
\fboxrule0.1pt
\fboxsep0pt
\fbox{hello world}\newline
\fbox{hello world}\newline
\fbox{hello world}\newline
% FOLLOWING DIM EXPRESSION IS NOT ENOUGH TO ALIGN THE NODE FRAME EXACTLY BELOW THE \fbox OF THE PARAGRAPH-LINE (NODE FRAME IS SLIGHTLY HIGHER THAN THE \fbox FRAME)
\vspace{\dimexpr-\lineskip-\baselineskip+0.1pt}
\begin{tikzpicture}
% 25mm (WIDTH OF LAST LINE, CONSIDERING INDENT OF 15mm) IS TOO WIDE, SO THE NODE FRAME OVERLAPS WITH THE PAGE FRAME; 24mm IS NOT APPROPRIATE WIDTH TO ALIGN THE NODE FRAME AT DOCUMENT BOUND WITHOUT WITHOUT OVERLAP
\path node[draw,text width=24mm]
{ \parbox{\hsize}
{ \begin{gather*}
2+2=4
\end{gather*}
}
};
\end{tikzpicture}
}
};
\end{tikzpicture}
\end{document}
You can use your own approach and completely modify this code sample so that it's unrecognizable from the original. What I care about is making the conditions described above work.
PROGRESS:
UPDATE: this answer (by egreg) solved how to position math-equation node-frame right below the frame of the \fbox
by reducing \newline\vspace{\dimexpr-\lineskip-\baselineskip+0.1pt}
to \vspace{-\lineskip}\newline
. But generating vertical space between those frames equal to interline-spacing is still unsolved problem. I guess we can use 1ex
or something font-size dependent to generate vertical space where we don't have interline-space length available. Let's make it 1ex then: \vspace{\dimexpr-\lineskip+1ex}\newline
.
UPDATE: (David Carlisle suggested that) aside from using standalone
class with tikz
option to crop height of pages, \pdfpageheight
can be used.
UPDATE: It's been suggested (by marmot) not to nest tikz
pictures directly but to save them in boxes instead (to avoid confusing tikz
and, therefore, avoid unexpected behavior; tikz
doesn't expect picture environments to be directly nested inside other picture environments, that's my take from the links provided).
UPDATE: Great progress on alignment of node frames has been made. It turns out, when you set inner sep
to zero, the text width
starts at the middle of frame's left side and extends to the middle of frame's right side. Similarly with text height: text starts at the middle of frame's top side and extends to the middle of frame's bottom side. This creates complexity by requiring inner node's text width
to "know" outer node's line width
, which can be avoided. (See this answer, by marmot.)
tikzpicture
s. There won't be a reliable solution as long as you keep doing this. See tex.stackexchange.com/q/47377/121799 and the posts linking to it in order to understand that nestingtikzpicture
s is really bad. – user121799 Jun 10 '19 at 20:19tikzpicture
s is necessary. All you innertikzpicture
seems to do is to draw a node. This you can do in the outertikzpicture
. If you want to remove the gaps, setouter sep=0pt
. – user121799 Jun 10 '19 at 20:28