von Phillip » Do 17. Mai 2018, 22:41
Hallo zusammen,
ich bekomme es leider nicht hin ein Listing neben ein Bild zu packen. Der Code bleibt zentral hinter dem Bild versteckt. Hoffe ihr habt eine schnelle Lösung für mich, danke im voraus!
\documentclass[12pt, a4paper]{report}
...
% Python Listing %%%%%%%%%%%%%%%%%%%%%%%%%%
% Default fixed font does not support bold face
\DeclareFixedFont{\ttb}{T1}{txtt}{bx}{n}{10} % for bold
\DeclareFixedFont{\ttm}{T1}{txtt}{m}{n}{10} % for normal
% Custom colors
\usepackage{color}
\definecolor{deepblue}{rgb}{0,0,0.5}
\definecolor{deepred}{rgb}{0.6,0,0}
\definecolor{deepgreen}{rgb}{0,0.5,0}
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
\usepackage{listings}
% Python style for highlighting
\newcommand\pythonstyle{\lstset{
language=Python,
basicstyle=\ttm,
otherkeywords={self}, % Add keywords here
keywordstyle=\ttb\color{deepblue},
morekeywords={*,...},
emph={MyClass,__init__}, % Custom highlighting
emphstyle=\ttb\color{deepred}, % Custom highlighting style
stringstyle=\color{deepgreen},
frame=single, % Any extra options here
showstringspaces=true,
numberstyle=\ttb\color{mygray},
rulecolor=\color{black},
numbers=left %
}}
% Python environment
\lstnewenvironment{python}[1][]
{
\pythonstyle
\lstset{#1}
}
{}
% Python for external files
\newcommand\pythonexternal[2][]{{
\pythonstyle
\lstinputlisting[#1]{#2}}}
% Python for inline
\newcommand\pythoninline[1]{{\pythonstyle\lstinline!#1!}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
...
\begin{document}
...
\begin{figure}[H]
\begin{minipage}[t]{.49\textwidth}
\begin{python}
def select_white(image):
lower = np.uint8([200,200,200])
upper = np.uint8([255,255,255])
white_mask = cv2.inRange(image, lower, upper)
return cv2.bitwise_and(image, image, mask = white_mask)
\end{python}
\end{minipage}
\hfill
\begin{minipage}[t]{.49\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{Bilder/Lanes/02_White.png}
\caption{Weiß-Filter}
\label{abb:lane_white}
\end{minipage}
\end{figure}
...
\end{document}
Den Code mit \begin{center} zentrieren hat leider auch nicht funktioniert
Hallo zusammen,
ich bekomme es leider nicht hin ein Listing neben ein Bild zu packen. Der Code bleibt zentral hinter dem Bild versteckt. Hoffe ihr habt eine schnelle Lösung für mich, danke im voraus!
[code]
\documentclass[12pt, a4paper]{report}
...
% Python Listing %%%%%%%%%%%%%%%%%%%%%%%%%%
% Default fixed font does not support bold face
\DeclareFixedFont{\ttb}{T1}{txtt}{bx}{n}{10} % for bold
\DeclareFixedFont{\ttm}{T1}{txtt}{m}{n}{10} % for normal
% Custom colors
\usepackage{color}
\definecolor{deepblue}{rgb}{0,0,0.5}
\definecolor{deepred}{rgb}{0.6,0,0}
\definecolor{deepgreen}{rgb}{0,0.5,0}
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
\usepackage{listings}
% Python style for highlighting
\newcommand\pythonstyle{\lstset{
language=Python,
basicstyle=\ttm,
otherkeywords={self}, % Add keywords here
keywordstyle=\ttb\color{deepblue},
morekeywords={*,...},
emph={MyClass,__init__}, % Custom highlighting
emphstyle=\ttb\color{deepred}, % Custom highlighting style
stringstyle=\color{deepgreen},
frame=single, % Any extra options here
showstringspaces=true,
numberstyle=\ttb\color{mygray},
rulecolor=\color{black},
numbers=left %
}}
% Python environment
\lstnewenvironment{python}[1][]
{
\pythonstyle
\lstset{#1}
}
{}
% Python for external files
\newcommand\pythonexternal[2][]{{
\pythonstyle
\lstinputlisting[#1]{#2}}}
% Python for inline
\newcommand\pythoninline[1]{{\pythonstyle\lstinline!#1!}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
...
\begin{document}
...
\begin{figure}[H]
\begin{minipage}[t]{.49\textwidth}
\begin{python}
def select_white(image):
lower = np.uint8([200,200,200])
upper = np.uint8([255,255,255])
white_mask = cv2.inRange(image, lower, upper)
return cv2.bitwise_and(image, image, mask = white_mask)
\end{python}
\end{minipage}
\hfill
\begin{minipage}[t]{.49\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{Bilder/Lanes/02_White.png}
\caption{Weiß-Filter}
\label{abb:lane_white}
\end{minipage}
\end{figure}
...
\end{document}
[/code]
Den Code mit \begin{center} zentrieren hat leider auch nicht funktioniert :(
[img]https://img2.picload.org/image/dooopirw/listing.png[/img]