@@ -184,7 +184,7 @@ function calloutDiv(div)
184184 return calloutDiv
185185end
186186
187- -- Latex awesomebox callout
187+ -- Latex callout
188188function calloutLatex (div )
189189
190190 -- read and clear attributes
@@ -194,40 +194,95 @@ function calloutLatex(div)
194194 div .attr .attributes [" icon" ] = nil
195195 div .attr .attributes [" caption" ] = nil
196196 div .attr .attributes [" collapse" ] = nil
197-
198- local calloutContents = pandoc .List :new ({});
199-
197+
200198 -- Add the captions and contents
199+ local calloutContents = pandoc .List :new ({});
201200 if caption ~= nil then
202201 calloutContents :insert (pandoc .Para (pandoc .Strong (caption )))
203202 end
204203 tappend (calloutContents , div .content )
205204
206- -- Add the environment info, using inlines if possible
205+ -- generate the callout box
206+ local callout = latexCalloutBox (type )
207+ local beginEnvironment = callout .beginInlines ;
208+ local endEnvironment = callout .endInlines ;
209+
210+ if calloutContents [1 ].t == " Para" and calloutContents [# calloutContents ].t == " Para" then
211+ tprepend (calloutContents [1 ].content , beginEnvironment )
212+ tappend (calloutContents [# calloutContents ].content , endEnvironment )
213+ else
214+ tprepend (calloutContents , pandoc .Para (beginEnvironment ))
215+ tappend (calloutContents , pandoc .Para (endEnvironment ))
216+ end
217+
218+
219+ return pandoc .Div (calloutContents )
220+ end
221+
222+ -- create the tcolorBox
223+ function latexCalloutBox (type , icon )
224+
225+ -- calllout dimensions
226+ local leftBorderWidth = ' 1mm'
227+ local borderWidth = ' .15mm'
228+ local borderRadius = ' .15mm'
229+ local leftPad = ' 2mm'
207230 local color = latexColorForType (type )
208- local leftMarginWidth = ' 0'
231+
232+ -- generate options
233+ local options = {
234+ colframe = color ,
235+ colback = ' white' ,
236+ left = leftPad ,
237+ leftrule = leftBorderWidth ,
238+ toprule = borderWidth ,
239+ bottomrule = borderWidth ,
240+ rightrule = borderWidth ,
241+ arc = borderRadius ,
242+ }
243+
244+ -- the core latex for the box
245+ local beginInlines = { pandoc .RawInline (' latex' , ' \\ begin{tcolorbox}[' .. tColorOptions (options ) .. ' ]\n ' ) }
246+ local endInlines = { pandoc .RawInline (' latex' , ' \n\\ end{tcolorbox}' ) }
247+
248+ -- generate the icon and use a minipage to position it
209249 local iconForType = iconForType (type )
210- local iconName = ' '
211250 if icon ~= false and iconForType ~= nil then
212- iconName = ' \\ ' .. iconForType
213- leftMarginWidth = ' 0.12'
251+ local iconName = ' \\ ' .. iconForType
252+ local iconColSize = ' 5.5mm'
253+
254+ -- add an icon to the begin
255+ local iconTex = ' \\ begin{minipage}[t]{' .. iconColSize .. ' }\n\\ textcolor{' .. color .. ' }{' .. iconName .. ' }\n\\ end{minipage}%\n\\ begin{minipage}[t]{\\ textwidth - ' .. iconColSize .. ' }\n '
256+ tappend (beginInlines , {pandoc .RawInline (' latex' , iconTex )})
257+
258+ -- close the icon
259+ tprepend (endInlines , {pandoc .RawInline (' latex' , ' \\ end{minipage}%' )});
214260 end
215- local separatorWidth = ' 1pt'
216261
217- local leftMargin = pandoc .RawInline (' latex' , ' \\ setlength{\\ aweboxleftmargin}{' .. leftMarginWidth .. ' \\ linewidth}' );
218- local beginEnvironment = pandoc .RawInline (' latex' , ' \\ begin{awesomeblock}[' .. color .. ' ]{' .. separatorWidth .. ' }{' .. iconName .. ' }{' .. color .. ' }\n ' )
219- local endEnvironment = pandoc .RawInline (' latex' , ' \n\\ end{awesomeblock}' )
220- if calloutContents [1 ].t == " Para" and calloutContents [# calloutContents ].t == " Para" then
221- table.insert (calloutContents [1 ].content , 1 , beginEnvironment )
222- table.insert (calloutContents [1 ].content , 1 , leftMargin )
223- table.insert (calloutContents [# calloutContents ].content , endEnvironment )
224- else
225- table.insert (calloutContents , 1 , pandoc .Para ({beginEnvironment }))
226- table.insert (calloutContents , pandoc .Para ({endEnvironment }))
262+ -- the inlines
263+ return {
264+ beginInlines = beginInlines ,
265+ endInlines = endInlines
266+ }
267+ end
268+
269+ -- generates a set of options for a tColorBox
270+ function tColorOptions (options )
271+
272+ local optionStr = " "
273+ local prepend = false
274+ for k , v in pairs (options ) do
275+ if (prepend ) then
276+ optionStr = optionStr .. ' , '
277+ end
278+ optionStr = optionStr .. k .. ' =' .. v
279+ prepend = true
227280 end
228- return pandoc .Div (calloutContents )
281+ return optionStr
282+
229283end
230284
285+
231286function calloutDocx (div )
232287
233288 local hasIcon , type , contents = resolveCalloutContents (div , false )
@@ -447,7 +502,7 @@ function iconForType(type)
447502 elseif type == " caution" then
448503 return " faBurn"
449504 elseif type == " tip" then
450- return " faLightbulb "
505+ return " faLightbulbO "
451506 else
452507 return nil
453508 end
0 commit comments