TeX - LaTeX Asked by Pxnt on July 17, 2021
I’m fairly new to working with LaTeX but I already very much enjoy using it. One of my latest ideas was creating a small side box, which contains informations regarding a section (I use this for a sheet full of coding tasks, which have an icon and an approximate amount of rows needed).
There are a few difficulties with this – the first one being the general concept of placing something outside of the normal margins. I’ve solved this by using a renewcommand{secimg}{ ... }
to surround my code for the side box, and I’m afraid I couldn’t for the life of me say why this works (this may be part of the problem).
The present issue arises, when I want to draw the box next to the relevant section title. Right now, the box seems to instead be drawn upwards from where I placed it – using vspace*
inside the box has no effect, and using it after the command is used results in less vertical space in the text, but the box still sitting awkwardly above the section title.
Here’s the code to reproduce the issue:
documentclass{article}
usepackage[many]{tcolorbox}
usepackage{titlesec} % for custom section titles
usepackage{lipsum}
tcbset{
sharp corners,
colback = white,
before skip = 0.2cm, % add extra space before the box
after skip = 0.5cm % add extra space after the box
}
newtcolorbox{recbox}{
colback = white,
colframe = black,
boxrule = 1pt,
toprule = 6pt,
width = 3em,
height = 4.2em,
top = 0.1em,
bottom = 0.2em,
right = 0em,
left = 0em,
before skip = 1em,
show bounding box
}
newcommand{secimg}{}
newcommand{rectwo}[2]{
renewcommand{secimg}{hspace{-5em}vspace*{5em}
begin{recbox}
centering
image
textbf{#1}
end{recbox}hspace{2em}
}}
titleformat{section}
{normalfontlargebfseries}
{secimg{}Section thesection hspace{1mm} -- }
{1mm}
{}
begin{document}
section{title}
lipsum[2]
rectwo{20 Z}
section{title}
lipsum[2-3]
end{document}
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP