# linebreak in tcolorbox

I'm new to LaTeX and am trying to get something like this in my document, i.e center aligning two lines inside a tcolorbox:

However I cannot get this as \linebreak doesn't seem to work with tcolorbox.

What I end up with is something like this :

Here's my code :

\documentclass[a4paper]{article}

%% Language and font encodings
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}

%% Sets page size and margins
\usepackage[a4paper,top=3cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}

%% Useful packages
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage{multicol}
\usepackage{algpseudocode}
\usepackage{tcolorbox}

\title{MPI}

\begin{document}
\maketitle

\begin{tcolorbox}[colback = white]
\textbf{{\color{blue} MPI\_Init(int *argc, char **argv) }}
\begin{align}
Input : argc, argv arguments \linebreak
return : MPI\_SUCCESS or error code
\end{align}
\end{tcolorbox}

\end{document}


Will be great if someone could show how to do it correctly.

• Welcome to TeX.SE. Please do not post such fragments only, post compilable documents. Apparently, you are trying to present Message Passing Interface C Code (or a description of this) -- have a look on the tcblisting library of tcolorbox here. Also align isn't the correct tool for this description anyway here -- it is a math mode environment, and the output of the characters in italics is clearly wrong – user31729 Oct 18 '17 at 20:59
• I'm sorry for not posting the compilable code. I'll try to edit the code. – ggulgulia Oct 18 '17 at 21:02
• btw i don't really care about the font of the code for the time being – ggulgulia Oct 18 '17 at 21:12

I suggest to use a tabular environment in order to describe the C function arguments.

This is not really meant for listings or tcblistings, but the function header can be typeset with \lstinline.

\documentclass[a4paper]{article}

%% Language and font encodings
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}

%% Sets page size and margins
\usepackage[a4paper,top=3cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}

%% Useful packages
\usepackage{amsmath}
%\usepackage{graphicx}
%\usepackage{wrapfig}
%\usepackage[colorinlistoftodos]{todonotes}
%\usepackage{multicol}
%\usepackage{algpseudocode}
\usepackage[most]{tcolorbox}
\usepackage{array}

\title{MPI}

\newcolumntype{D}{>{:}c}

\lstset{language={C}}

\newtcolorbox{MPIBox}[1][]{enhanced,sharp corners,colback = white,#1}

\begin{document}
\maketitle

\begin{MPIBox}
{\bfseries \color{blue}
\lstinline{MPI_Init(int *argc, char **argv)}
}

\begin{tabular}{@{\hskip2cm}p{2cm}Dp{5cm}}
Input  &  & argc, argv arguments \tabularnewline
return &  & MPI\_SUCCESS or error code
\end{tabular}
\end{MPIBox}

\end{document}


• thanks. This worked. Unfortunately I cannot upvote your answer as I am very new to the community – ggulgulia Oct 18 '17 at 21:33
• @gajendra: But you can accept the answer (and upvote later on, after having gained more reputation ;-)) – user31729 Oct 18 '17 at 21:36
• sorry.. i didn't know if that could be done. I just accepted it :) – ggulgulia Oct 18 '17 at 22:14