Text FormattingFormatting

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
funnyguy
Posts: 2
Joined: Mon Oct 21, 2019 1:12 pm

Formatting

Post by funnyguy »

Hi,

when compiled the code adds extra space between my words and the "[3 Min]" is put in two lines.

Why?

Code: Select all

\newcommand{\testt}[1]{\textbf{Aufgabe #1: {\thesection}}}

\def\mytcolorbox#1#2#3%
{%
    \begin{tcolorbox}%
    #1\hfill[#2 Min]%
    \tcblower%
    #3%
    \end{tcolorbox}%
}%

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

funnyguy
Posts: 2
Joined: Mon Oct 21, 2019 1:12 pm

Formatting

Post by funnyguy »

I call the macros like this:

\mytcolorbox{\testt{hello} text1 text2 text 3 and so on...}{3}{gut}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Formatting

Post by Stefan Kottwitz »

Hi,

welcome to the forum!

When I tested your code, there is no extra space between words and [3 min] is not put in two lines.

Perhaps you can post a Infominimal working example that shows the issue? Note, when you post an incomplete snippet, everybody who wants to test it has to build a document around. Not only is this multiple work, but it happens that this works different than your actual code. Happens here, it seems.

Code: Select all

\documentclass{article}
\usepackage{tcolorbox}
\newcommand{\testt}[1]{\textbf{Aufgabe #1: {\thesection}}}
     
\def\mytcolorbox#1#2#3%
    {%
        \begin{tcolorbox}%
        #1\hfill[#2 Min]%
        \tcblower%
        #3%
        \end{tcolorbox}%
    }%
\begin{document} 
\mytcolorbox{\testt{hello} text1 text2 text 3 and so on...}{3}{gut}  
\end{document}
aufgabe.png
aufgabe.png (10.65 KiB) Viewed 2103 times
Stefan
LaTeX.org admin
Post Reply