Quantcast
Channel: Parbox as an initial - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 4

Answer by user4686 for Parbox as an initial

$
0
0

This is a rip-off from egreg's answer, but I modified it in order to obtain the line alignment you requested. The role of the optional parameter to \begin{definition} is now something else: if present it has to be of the form number,number as in 2,3 and it then means "put 2 blank lines before and 3 after". The stuff will thus be displayed on the third line, and the indentation will cease with the seventh line. Here is an example with 2 lines before and after:

e=mc^2 as a lettrine

Update: I have edited the code so that the argument is centered with 15% space before and after. The new look is:

e=mc^2 as a centered lettrine

\documentclass{article}\usepackage{lipsum}\newsavebox{\defbox}\newcount\mycount\newtoks\strutlines\def\numbefore #1,#2,{#1}\def\numafter #1,#2,{#2}\def\numtotal #1,#2,{\numexpr #1+#2+1}\def\insertstrutlines #1{\mycount=#1\strutlines={}%\loop\ifnum\mycount > 0 \advance\mycount by -1\relax \expandafter\strutlines\expandafter{\the\strutlines \strut \\} \repeat\the\strutlines}\newenvironment{definition}[2][1,1]{%    \sbox\defbox{%        \begin{tabular}[t]{@{}c@{}}         \insertstrutlines{\numbefore #1,}         \strut\smash{#2}\\         \insertstrutlines{\numafter #1,}        \end{tabular}}%  \par\addvspace{\topsep}  \hangindent=1.3\wd\defbox \hangafter-\numtotal #1,  \noindent\llap{%    \makebox[1.3\wd\defbox][c]{\smash{\usebox\defbox}}}%  \ignorespaces} {\par\addvspace{\topsep}}\begin{document}\begin{definition}{$\displaystyle\int_0^{2s} f''(t)\mathrm{d}t$}\lipsum[1]\end{definition}\begin{definition}[1,2]{$\int_0^{2s} f''(t)\mathrm{d}t = f'(2s)-f'(0)$}\lipsum[2]\end{definition}\begin{definition}[2,2]{\huge $E = m c^2$}  \lipsum[6]\end{definition}\end{document}

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>