2

I am trying to create custom info boxes (very similar as in awesomebox package).

The and everything sims is fine except when the box is not surrounded with some text. Then I get an error There's no line here to end.

I guess the error is because of \bigskip\newline in my macros. I used it to create extra paddings on top and bottom of the environment and macros

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=2cm]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{fontawesome}
\parindent=0ex
\usepackage{xcolor}

% RED
\definecolor{redSeven}{rgb}{0.94, 0.24, 0.24}
\definecolor{redNine}{rgb}{0.79, 0.16, 0.16}

% ORANGE
\definecolor{orangeSeven}{rgb}{0.97, 0.4, 0.03}
\definecolor{orangeNine}{rgb}{0.85, 0.28, 0.06}

%    BANS ----------------------------------------------------------------------

\newcommand{\banBox}[2][ban]{%
    \bigskip\newline
    \begin{minipage}{.1\textwidth}\centering
        \textcolor{redSeven}{\fontsize{16}{24}\faicon{#1}}
    \end{minipage}%
    \textcolor{redSeven}{\vrule width 3pt \hspace{14pt}}
    \begin{minipage}{.8\textwidth}
        \textcolor{redNine}{#2}
    \end{minipage}
    \smallskip\newline
}

\newenvironment{banEnv}[1][ban]%
{\bigskip\newline%
    \begin{minipage}{.1\textwidth}\centering%
        \textcolor{redSeven}{\fontsize{16}{24}\faicon{#1}}%
    \end{minipage}%
    \textcolor{redSeven}{\vrule width 3pt \hspace{14pt}}%
    \begin{minipage}{.8\textwidth}
        \color{redNine}}
    {\end{minipage}\bigskip\newline}

%    WARNINGS ------------------------------------------------------------------

\newcommand{\warningBox}[2][exclamation-triangle]{%
    \bigskip \newline
    \begin{minipage}{.1\textwidth}\centering
        \textcolor{orangeSeven}{\fontsize{16}{24}\faicon{#1}}
    \end{minipage}%
    \textcolor{orangeSeven}{\vrule width 3pt \hspace{14pt}}
    \begin{minipage}{.8\textwidth}
        \textcolor{orangeNine}{#2}
    \end{minipage}
    \newline
}

\newenvironment{warningEnv}[1][exclamation-triangle]%
{\bigskip\newline
    \begin{minipage}{.1\textwidth}\centering%
        \textcolor{orangeSeven}{\fontsize{16}{24}\faicon{#1}}%
    \end{minipage}%
    \textcolor{orangeSeven}{\vrule width 3pt \hspace{14pt}}%
    \begin{minipage}{.8\textwidth}
        \color{orangeNine}}
    {\end{minipage}\bigskip\newline}

%-------------------------------------------------------------------------------

\begin{document}

Comment this line or Delete any commented line bellow
\banBox{Ban box.}
% A
\begin{banEnv}
    Ban environment.\\
    Lorem ipsum dolor sit amet.\\
    Earum odit quia maiores nisi illum reiciendis aspernatur.
\end{banEnv}
% B
\warningBox{Warning box.}
% C
\begin{warningEnv}
    Warning environment.\\
    Lorem ipsum dolor sit amet\\
    Earum odit quia maiores nisi illum reiciendis aspernatur.
\end{warningEnv}
% D

\end{document}

Updated: The worst case if is no line in between.

\begin{document}

    \banBox{Ban box.}

    \begin{banEnv}
        Ban environment.\\
        Lorem ipsum dolor sit amet.\\
        Earum odit quia maiores nisi illum reiciendis aspernatur.
    \end{banEnv}

    \warningBox{Warning box.}

    \begin{warningEnv}
        Warning environment.\\
        Lorem ipsum dolor sit amet\\
        Earum odit quia maiores nisi illum reiciendis aspernatur.
    \end{warningEnv}


\end{document}
6

I have added a space character before \bigskip\newline for \newline command. Such as:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=2cm]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{fontawesome}
\parindent=0ex
\usepackage{xcolor}

% RED
\definecolor{redSeven}{rgb}{0.94, 0.24, 0.24}
\definecolor{redNine}{rgb}{0.79, 0.16, 0.16}

% ORANGE
\definecolor{orangeSeven}{rgb}{0.97, 0.4, 0.03}
\definecolor{orangeNine}{rgb}{0.85, 0.28, 0.06}

%    BANS ----------------------------------------------------------------------

\newcommand{\banBox}[2][ban]{%
    \ \bigskip\newline         % <----------------- added \ and space
    \begin{minipage}{.1\textwidth}\centering
        \textcolor{redSeven}{\fontsize{16}{24}\faicon{#1}}
    \end{minipage}%
    \textcolor{redSeven}{\vrule width 3pt \hspace{14pt}}
    \begin{minipage}{.8\textwidth}
        \textcolor{redNine}{#2}
    \end{minipage}
    \smallskip\newline
}

\newenvironment{banEnv}[1][ban]%
{\bigskip\newline%
    \begin{minipage}{.1\textwidth}\centering%
        \textcolor{redSeven}{\fontsize{16}{24}\faicon{#1}}%
    \end{minipage}%
    \textcolor{redSeven}{\vrule width 3pt \hspace{14pt}}%
    \begin{minipage}{.8\textwidth}
        \color{redNine}}
    {\end{minipage}\bigskip\newline}

%    WARNINGS ------------------------------------------------------------------

\newcommand{\warningBox}[2][exclamation-triangle]{%
    \bigskip \newline
    \begin{minipage}{.1\textwidth}\centering
        \textcolor{orangeSeven}{\fontsize{16}{24}\faicon{#1}}
    \end{minipage}%
    \textcolor{orangeSeven}{\vrule width 3pt \hspace{14pt}}
    \begin{minipage}{.8\textwidth}
        \textcolor{orangeNine}{#2}
    \end{minipage}
    \newline
}

\newenvironment{warningEnv}[1][exclamation-triangle]%
{\bigskip\newline
    \begin{minipage}{.1\textwidth}\centering%
        \textcolor{orangeSeven}{\fontsize{16}{24}\faicon{#1}}%
    \end{minipage}%
    \textcolor{orangeSeven}{\vrule width 3pt \hspace{14pt}}%
    \begin{minipage}{.8\textwidth}
        \color{orangeNine}}
    {\end{minipage}\bigskip\newline}

%-------------------------------------------------------------------------------

\begin{document}

%Comment this line or Delete any commented line bellow
\banBox{Ban box.}
 A
\begin{banEnv}
    Ban environment.\\
    Lorem ipsum dolor sit amet.\\
    Earum odit quia maiores nisi illum reiciendis aspernatur.
\end{banEnv}
 B
\warningBox{Warning box.}
 C
\begin{warningEnv}
    Warning environment.\\
    Lorem ipsum dolor sit amet\\
    Earum odit quia maiores nisi illum reiciendis aspernatur.
\end{warningEnv}
 D
\end{document}

enter image description here

ADDENDUM:

If we remove the A, B, C and D lines, output is follow:

    \documentclass[12pt,a4paper]{article}
    \usepackage[utf8]{inputenc}
    \usepackage[margin=2cm]{geometry}
    \usepackage{amsmath}
    \usepackage{amsfonts}
    \usepackage{amssymb}
    \usepackage{graphicx}
    \usepackage{fontawesome}
    \parindent=0ex
    \usepackage{xcolor}

    % RED
    \definecolor{redSeven}{rgb}{0.94, 0.24, 0.24}
    \definecolor{redNine}{rgb}{0.79, 0.16, 0.16}

    % ORANGE
    \definecolor{orangeSeven}{rgb}{0.97, 0.4, 0.03}
    \definecolor{orangeNine}{rgb}{0.85, 0.28, 0.06}

    %    BANS ----------------------------------------------------------------------

    \newcommand{\banBox}[2][ban]{%
        \ \bigskip\newline
        \begin{minipage}{.1\textwidth}\centering
            \textcolor{redSeven}{\fontsize{16}{24}\faicon{#1}}
        \end{minipage}%
        \textcolor{redSeven}{\vrule width 3pt \hspace{14pt}}
        \begin{minipage}{.8\textwidth}
            \textcolor{redNine}{#2}
        \end{minipage}
        \smallskip\newline
    }

    \newenvironment{banEnv}[1][ban]%
    {\ \bigskip\newline%
        \begin{minipage}{.1\textwidth}\centering%
            \textcolor{redSeven}{\fontsize{16}{24}\faicon{#1}}%
        \end{minipage}%
        \textcolor{redSeven}{\vrule width 3pt \hspace{14pt}}%
        \begin{minipage}{.8\textwidth}
            \color{redNine}}
        {\end{minipage}\bigskip\newline}

    %    WARNINGS ------------------------------------------------------------------

    \newcommand{\warningBox}[2][exclamation-triangle]{%
       \ \bigskip \newline
        \begin{minipage}{.1\textwidth}\centering
            \textcolor{orangeSeven}{\fontsize{16}{24}\faicon{#1}}
        \end{minipage}%
        \textcolor{orangeSeven}{\vrule width 3pt \hspace{14pt}}
        \begin{minipage}{.8\textwidth}
            \textcolor{orangeNine}{#2}
        \end{minipage}
        \newline
    }

    \newenvironment{warningEnv}[1][exclamation-triangle]%
    {\ \bigskip\newline
        \begin{minipage}{.1\textwidth}\centering%
            \textcolor{orangeSeven}{\fontsize{16}{24}\faicon{#1}}%
        \end{minipage}%
        \textcolor{orangeSeven}{\vrule width 3pt \hspace{14pt}}%
        \begin{minipage}{.8\textwidth}
            \color{orangeNine}}
        {\end{minipage}\bigskip\newline}

    %-------------------------------------------------------------------------------

   \begin{document}

    \banBox{Ban box.}

    \begin{banEnv}
        Ban environment.\\
        Lorem ipsum dolor sit amet.\\
        Earum odit quia maiores nisi illum reiciendis aspernatur.
    \end{banEnv}

    \warningBox{Warning box.}

    \begin{warningEnv}
        Warning environment.\\
        Lorem ipsum dolor sit amet\\
        Earum odit quia maiores nisi illum reiciendis aspernatur.
    \end{warningEnv}

    \end{document}

enter image description here

  • it does'n work if you remove the text in between (A, B, C, D) – Igor Apr 1 at 21:11
  • 1
    It works. Check out my addendum. – ferahfeza Apr 1 at 21:16
  • 1
    @ferahfeza I like it. My congratulations. – Sebastiano Apr 1 at 21:17
  • @Igor, add \ to each \bigskip\newline – ferahfeza Apr 1 at 21:23
  • @Igor, your welcome. – ferahfeza Apr 1 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.