www.xbdev.net
xbdev - software development
Saturday January 16, 2021
home | about | contact | Donations

     
 

LaTeX

Beautiful, Powerful and Fun Document Tools (but requires a little extra work)

 


Various examples of adding 'block' comment boxes to a document page to emphasis or point out important facts, notes or information to the reader. The example LaTeX code shows a full working example with different styles/formatting depending on your preference.



\documentclass[a4paper]{article}
\usepackage[a4paper, total={6in, 8in}]{geometry}

\usepackage{environ}
\usepackage{xcolor}
\usepackage[tikz]{bclogo}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}

\NewEnviron{myremark}[1]
{\par\medskip\noindent
	\begin{tikzpicture}
	\node[inner sep=0pt] (box) {\parbox[t]{.99\textwidth}{%
			\begin{minipage}{.3\textwidth}
			\centering\tikz[scale=5]\node[scale=3,rotate=30]{\bclampe};
			\end{minipage}%
			\begin{minipage}{.65\textwidth}
			\textbf{#1}\par\smallskip
			\BODY
			\end{minipage}\hfill}%
	};
	\draw[red!75!black,line width=3pt] 
	( $ (box.north east) + (-5pt,3pt) $ ) -- ( $ (box.north east) + (0,3pt) $ ) -- ( $ (box.south east) + (0,-3pt) $ ) -- + (-5pt,0);
	\draw[red!75!black,line width=3pt] 
	( $ (box.north west) + (5pt,3pt) $ ) -- ( $ (box.north west) + (0,3pt) $ ) -- ( $ (box.south west) + (0,-3pt) $ ) -- + (5pt,0);
	\end{tikzpicture}\par\medskip%
}


\definecolor{mycolor}{rgb}{0.835,0.937,0.76}


\NewEnviron{mynote}[1]
{\par\medskip\noindent
	\begin{tikzpicture}
	\node[inner sep=0pt, fill=mycolor,line width=0.5mm,draw=black!2] (box) {\parbox[t]{.95\textwidth}{%
			\begin{minipage}{.09\textwidth}
			%\centering\tikz[scale=5]\node[scale=3,rotate=30]{tipicon.png};
			%\includegraphics[width=0.9\textwidth]{tipicon.png}
			\hspace{1cm}
			
			\end{minipage}%
			\begin{minipage}{.82\textwidth}
			\par\bigskip
			\textbf{#1}\par\smallskip
			\BODY
			\par\bigskip
			\end{minipage}\hfill}%
	};
	\node[right=10pt] at ( $ (box.north west) + (-1.1,-1) $ ) { \includegraphics[width=0.1\textwidth]{tipicon.png} };
	\end{tikzpicture}\par\medskip%
}





\usepackage[most]{tcolorbox}

%textmarker style from colorbox doc
\tcbset{textmarker/.style={%
		enhanced,
		parbox=false,boxrule=0mm,boxsep=0mm,arc=0mm,
		outer arc=0mm,left=6mm,right=3mm,top=7pt,bottom=7pt,
		toptitle=1mm,bottomtitle=1mm,oversize}}


% define new colorboxes
\newtcolorbox{hintBox}{textmarker,
	borderline west={6pt}{0pt}{yellow},
	colback=yellow!10!white}
\newtcolorbox{importantBox}{textmarker,
	borderline west={6pt}{0pt}{red},
	colback=red!10!white}
\newtcolorbox{noteBox}{textmarker,
	borderline west={6pt}{0pt}{green},
	colback=green!10!white}

% define commands for easy access
\newcommand{\note}[1]{\begin{noteBox} \textbf{Note:} #1 \end{noteBox}}
\newcommand{\warning}[1]{\begin{hintBox} \textbf{Warning:} #1 \end{hintBox}}
\newcommand{\important}[1]{\begin{importantBox} \textbf{Important:} #1 \end{importantBox}}


\begin{document}
	
	\textbf{Various examples of adding 'block' comment boxes to a document page to emphasis or point out important facts, notes or information to the reader}
	
	
	
	\begin{myremark}{Web addresses in texts}
		\lipsum[2]
	\end{myremark}
	
	
	\begin{mynote}{Web addresses in texts}
		\lipsum[2]
	\end{mynote}


	\note{Sometimes it's extremely useful to have clear well thought out notes that popout on a page - this is useful for the reader and for the writer.}
	\warning{There are facts or details which are dangerous or important that need to be emphasised as a warning, for example, you shouldn't put a fork in a toaster (especially when it's plugged in and on).}
	\important{Crucial details - so important that they need to be put in red!  Stop and pay attention.}
	
	
	\vspace{10pt}
	Tip Icon:
	
	\includegraphics[width=0.2\textwidth]{tipicon.png}
	
	
\end{document}











 

 
 Visitor: 9534626
{ 229.27.38.75 }
Copyright (c) 2002-2020 xbdev.net - All rights reserved.
Designated articles, tutorials and software are the property of their respective owners.