Re: [NTG-context] tabulate inside itemize
THANKS ADITYA! I got Wolfgang's solution first and it works great. But I think there are some things in your solution that I should try to learn about. :) > -Original Message- > From: ntg-context [mailto:ntg-context-boun...@ntg.nl] On Behalf Of Aditya > Mahajan > Sent: Wednesday, July 29, 2020 11:12 AM > To: mailing list for ConTeXt users > Subject: Re: [NTG-context] tabulate inside itemize > > On Wed, 29 Jul 2020, Mike Cooper wrote: > > > I would normally use tab stops and line breaks to achieve the following in a > numbered list: > > > > 1. DC = 3.20 bbl = 420 ft > >HWDP = 3.90 bbl = 450 ft > >DP = 34.63 bbl = 2,037 ft > >Totals = 41.73 bbl = 2,907 ft > > > > 2. [next step …] > > > > > > This is what I tried, but the output has a blank line at the number. I > > can’t find > anything about tabulate inside itemize. > > > > \starttext > > > > \startitemize[n] > >\startitem \starttabulate[|l|l|r|l|r|] > >\NC DC \NC = \NC 3.20 bbl \NC = \NC 420 > > ft \NC \NR > >\NC HWDP \NC = \NC 3.90 bbl \NC = \NC > > 450 ft \NC \NR > >\NC DP \NC = \NC 34.63 bbl \NC = \NC > > 2,037 ft \NC \NR > >\NC DC \NC = \NC 41.73 bbl \NC = \NC > > 2,907 ft \NC \NR > >\stoptabulate \stopitem > >\startitem Convert 2,907 to TVD: \\TVD = 2,907 × cosine 45° = > > 2,907 × > 0.707 = 2,056 ft \stopitem > >\startitem ΔP = 2,056 ft × 0.052 × (15 - 7.2) = 834 psi > > \stopitemize > > > > \stoptext > > Naive solution: Add a \hbox around tabulate: > > > \defineframed[tabulateframed][location=top,frame=off] > > \starttext > > \startitemize[n] > \startitem \dontleavehmode >\tabulateframed{\starttabulate[|l|l|r|l|r|] > \NC DC \NC = \NC 3.20 bbl \NC = \NC 420 > ft \NC \NR > \NC HWDP \NC = \NC 3.90 bbl \NC = \NC > 450 ft \NC \NR > \NC DP \NC = \NC 34.63 bbl \NC = \NC > 2,037 ft \NC \NR > \NC DC \NC = \NC 41.73 bbl \NC = \NC > 2,907 ft \NC \NR > \stoptabulate} \stopitem > \startitem Convert 2,907 to TVD: \\TVD = 2,907 × cosine 45° = > 2,907 × > 0.707 = 2,056 ft \stopitem > \startitem ΔP = 2,056 ft × 0.052 × (15 - 7.2) = 834 psi > \stopitemize > > \stoptext > > Normally, you can fix such issues by appending a \dontleavehmode in front of > the > command but that doesn't work here. The offending code is line 1300 of tabl- > tbl.mkxl: > > \unexpanded\def\tabl_tabulate_outside_before >{\ifhmode\par\fi > \ifhmode > \vbox\bgroup > \let\tabl_tabulate_outside_after\egroup > \let\tabl_tabulate_outside_inbetween\relax > \orelse\ifinner > \let\tabl_tabulate_outside_after\relax > \let\tabl_tabulate_outside_inbetween\relax > \else > \whitespace > \tabulationparameter\c!before > \relax > \let\tabl_tabulate_outside_after\tabl_tabulate_outside_after_indeed > > \let\tabl_tabulate_outside_inbetween\tabl_tabulate_outside_inbetween_indeed > \fi} > \protect > > When you use \dontleavehmode\starttabulate, \starttabulate starts in > horizontal > mode but the first \par in the above command takes it back to vertical mode. > The > next \ifhmode then evaluates to false, \ifinner also evaluates to false, so > we enter > the \else loop which inserts a \whitespace. > > The reason why adding a \hbox{...} (which is what \framed without an align key > does) works is because inside an \hbox{...} \par doesn't take TeX back to > vertical > mode. So, we enter the first branch. > > Aditya ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] tabulate inside itemize
THANKS HANS! I got Wolfgang's solution first and it works great. > -Original Message- > From: ntg-context [mailto:ntg-context-boun...@ntg.nl] On Behalf Of Hans Hagen > Sent: Wednesday, July 29, 2020 11:11 AM > To: mailing list for ConTeXt users > Subject: Re: [NTG-context] tabulate inside itemize > > On 7/29/2020 6:38 PM, Mike Cooper wrote: > > I would normally use tab stops and line breaks to achieve the following > > in a numbered list: > I know this looks terrible: > > \define\MyTabulateHack{\vskip-\lineheight\blank[disable]} > > \startitemize[n] > > \startitem \MyTabulateHack > \starttabulate[|l|l|r|l|r|] > > but it kind of works ok in your case. > > Hans > > - >Hans Hagen | PRAGMA ADE >Ridderstraat 27 | 8061 GH Hasselt | The Netherlands > tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl > - > ___ > > If your question is of interest to others as well, please add an entry to the > Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > ___ > ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] tabulate inside itemize
On 7/29/2020 7:09 PM, Wolfgang Schuster wrote: Mike Cooper schrieb am 29.07.2020 um 18:38: I would normally use tab stops and line breaks to achieve the following in a numbered list: 1. DC=3.20 bbl =420 ft HWDP= 3.90 bbl =450 ft DP= 34.63 bbl = 2,037 ft Totals = 41.73 bbl = 2,907 ft 2. [next step …] This is what I tried, but the output has a blank line at the number.I can’t find anything about tabulate inside itemize. \starttext \startitemize[n] \startitem \starttabulate[|l|l|r|l|r|] \NC DC \NC = \NC 3.20 bbl \NC = \NC 420 ft \NC \NR \NC HWDP \NC = \NC 3.90 bbl \NC = \NC 450 ft \NC \NR \NC DP \NC = \NC 34.63 bbl \NC =\NC 2,037 ft \NC \NR \NC DC \NC = \NC 41.73 bbl \NC =\NC 2,907 ft \NC \NR \stoptabulate \stopitem \startitem Convert 2,907 to TVD: \\TVD = 2,907 × cosine 45° = 2,907 × 0.707 = 2,056 ft \stopitem \startitem ΔP = 2,056 ft × 0.052 × (15 – 7.2) = 834 psi \stopitemize \stoptext Is there some way to stop the blank line or should I use an entirely different approach? 1. Use \blank[overlay] to continue on the first line of the item entry Ah ... I start forgetting things ... bad ... (I should use tex more often I guess) Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] tabulate inside itemize
On Wed, 29 Jul 2020, Mike Cooper wrote: I would normally use tab stops and line breaks to achieve the following in a numbered list: 1. DC = 3.20 bbl = 420 ft HWDP = 3.90 bbl = 450 ft DP = 34.63 bbl = 2,037 ft Totals = 41.73 bbl = 2,907 ft 2. [next step …] This is what I tried, but the output has a blank line at the number. I can’t find anything about tabulate inside itemize. \starttext \startitemize[n] \startitem \starttabulate[|l|l|r|l|r|] \NC DC \NC = \NC 3.20 bbl \NC = \NC 420 ft \NC \NR \NC HWDP \NC = \NC 3.90 bbl \NC = \NC 450 ft \NC \NR \NC DP \NC = \NC 34.63 bbl \NC = \NC 2,037 ft \NC \NR \NC DC \NC = \NC 41.73 bbl \NC = \NC 2,907 ft \NC \NR \stoptabulate \stopitem \startitem Convert 2,907 to TVD: \\TVD = 2,907 × cosine 45° = 2,907 × 0.707 = 2,056 ft \stopitem \startitem ΔP = 2,056 ft × 0.052 × (15 - 7.2) = 834 psi \stopitemize \stoptext Naive solution: Add a \hbox around tabulate: \defineframed[tabulateframed][location=top,frame=off] \starttext \startitemize[n] \startitem \dontleavehmode \tabulateframed{\starttabulate[|l|l|r|l|r|] \NC DC \NC = \NC 3.20 bbl \NC = \NC 420 ft \NC \NR \NC HWDP \NC = \NC 3.90 bbl \NC = \NC 450 ft \NC \NR \NC DP \NC = \NC 34.63 bbl \NC = \NC 2,037 ft \NC \NR \NC DC \NC = \NC 41.73 bbl \NC = \NC 2,907 ft \NC \NR \stoptabulate} \stopitem \startitem Convert 2,907 to TVD: \\TVD = 2,907 × cosine 45° = 2,907 × 0.707 = 2,056 ft \stopitem \startitem ΔP = 2,056 ft × 0.052 × (15 - 7.2) = 834 psi \stopitemize \stoptext Normally, you can fix such issues by appending a \dontleavehmode in front of the command but that doesn't work here. The offending code is line 1300 of tabl-tbl.mkxl: \unexpanded\def\tabl_tabulate_outside_before {\ifhmode\par\fi \ifhmode \vbox\bgroup \let\tabl_tabulate_outside_after\egroup \let\tabl_tabulate_outside_inbetween\relax \orelse\ifinner \let\tabl_tabulate_outside_after\relax \let\tabl_tabulate_outside_inbetween\relax \else \whitespace \tabulationparameter\c!before \relax \let\tabl_tabulate_outside_after\tabl_tabulate_outside_after_indeed \let\tabl_tabulate_outside_inbetween\tabl_tabulate_outside_inbetween_indeed \fi} \protect When you use \dontleavehmode\starttabulate, \starttabulate starts in horizontal mode but the first \par in the above command takes it back to vertical mode. The next \ifhmode then evaluates to false, \ifinner also evaluates to false, so we enter the \else loop which inserts a \whitespace. The reason why adding a \hbox{...} (which is what \framed without an align key does) works is because inside an \hbox{...} \par doesn't take TeX back to vertical mode. So, we enter the first branch. Aditya ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] tabulate inside itemize
On 7/29/2020 6:38 PM, Mike Cooper wrote: > I would normally use tab stops and line breaks to achieve the following > in a numbered list: I know this looks terrible: \define\MyTabulateHack{\vskip-\lineheight\blank[disable]} \startitemize[n] \startitem \MyTabulateHack \starttabulate[|l|l|r|l|r|] but it kind of works ok in your case. Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] tabulate inside itemize
Mike Cooper schrieb am 29.07.2020 um 18:38: I would normally use tab stops and line breaks to achieve the following in a numbered list: 1. DC=3.20 bbl =420 ft HWDP= 3.90 bbl =450 ft DP= 34.63 bbl = 2,037 ft Totals = 41.73 bbl = 2,907 ft 2. [next step …] This is what I tried, but the output has a blank line at the number.I can’t find anything about tabulate inside itemize. \starttext \startitemize[n] \startitem \starttabulate[|l|l|r|l|r|] \NC DC \NC = \NC 3.20 bbl \NC = \NC 420 ft \NC \NR \NC HWDP \NC = \NC 3.90 bbl \NC = \NC 450 ft \NC \NR \NC DP \NC = \NC 34.63 bbl \NC =\NC 2,037 ft \NC \NR \NC DC \NC = \NC 41.73 bbl \NC =\NC 2,907 ft \NC \NR \stoptabulate \stopitem \startitem Convert 2,907 to TVD: \\TVD = 2,907 × cosine 45° = 2,907 × 0.707 = 2,056 ft \stopitem \startitem ΔP = 2,056 ft × 0.052 × (15 – 7.2) = 834 psi \stopitemize \stoptext Is there some way to stop the blank line or should I use an entirely different approach? 1. Use \blank[overlay] to continue on the first line of the item entry 2. Disable the blank line at the start of the table with "before=" \starttext \startitemize[n] \startitem \blank[overlay] \starttabulate[|l|c|r|c|r|][before=,after=] \NC DC \NC = \NC 3.20 bbl \NC = \NC 420 ft \NC\NR \NC HWDP \NC = \NC 3.90 bbl \NC = \NC 450 ft \NC\NR \NC DP \NC = \NC 34.63 bbl \NC = \NC 2,037 ft \NC\NR \NC DC \NC = \NC 41.73 bbl \NC = \NC 2,907 ft \NC\NR \stoptabulate \stopitem \startitem Convert 2,907 to TVD:\crlf TVD = 2,907 × cosine 45° = 2,907 × 0.707 = 2,056 ft \stopitem \startitem ΔP = 2,056 ft × 0.052 × (15 – 7.2) = 834 psi \stopitem \stopitemize \stoptext You can also get rid of the = in your table when you use the \EQ column separator and set the sign for the separator to =. \starttext \starttabulate[|l|r|r|][EQ={=}] \NC DC \EQ 3.20 bbl \EQ 420 ft \NC\NR \NC HWDP \EQ 3.90 bbl \EQ 450 ft \NC\NR \NC DP \EQ 34.63 bbl \EQ 2,037 ft \NC\NR \NC DC \EQ 41.73 bbl \EQ 2,907 ft \NC\NR \stoptabulate \stoptext Wolfgang ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___