更新2:
没关系,我犯了一个错误,包含了一个额外的 \begin{center}。删除它就可以解决问题。
Thorbjørns 解决方案的更新
我没能让它工作起来。
当我添加前标题时,它可以工作,但是 sharelatex 会将所有内容标记为红色,如下所示 我收到以下错误:
Extra }, or forgotten \endgroup.
\maketitle ...\@bspretitle \@title \@bsposttitle }
\maketitlehookb {\@bsprea...
l.48 \maketitle
I've deleted a group-closing symbol because it seems to be
spurious, as in `$x}$'. But perhaps the } is legitimate and
you forgot something else, as in `\hbox{$x}'. In such cases
the way to recover is to insert both the forgotten and the
deleted material, e.g., by typing `I$}'.
main.tex, line 48
LaTeX Error: \begin{center} on input line 48 ended by \end{titlepage}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
.
l.48 \maketitle
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
main.tex, line 69
LaTeX Error: \begin{titlepage} on input line 48 ended by \end{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
. l.69 \end{document}
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
main.tex
Package Fancyhdr Warning: \headheight is too small (52.16212pt): Make it at least 104.08003pt. We now make it that large for the rest of the document. This may cause the page layout to be inconsistent, however.
这是我更新后的代码:
\documentclass[11pt,a4paper,titlepage]{article}
%packs
\usepackage[utf8]{inputenc}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[demo]{graphicx}
\usepackage{fourier}
\usepackage{titling}
\usepackage{fancyhdr}
\usepackage[margin=1in,headsep=.2in]{geometry}
\usepackage{subfig}
\usepackage[export]{adjustbox}
\usepackage{subfiles}
\usepackage{rotating}
\usepackage{relsize}
\usepackage{mathtools}
\pagestyle{fancy}
\date{\today}
\author{Peter Sloth Mierzwa, S154194 \qquad \qquad \qquad Jakob Will Iversen S143262}
\title{Kursusopgave 5, 62738 Digital signalbehandling E16 }
%headers and footers
\rhead{\includegraphics[width=3cm]{pics/DTUlogo.png}}
\lhead{Peter Sloth Mierzwa S154194, Jakob W. Iversen S143262}
\renewcommand{\headrulewidth}{2pt}
\setlength{\headheight}{52.16212pt}
%
\pretitle{\begin{center}\Large}
\posttitle{%
\begin{center}
\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=6cm]{pics/UserPicture.png}
\end{minipage}
\qquad
\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=6cm]{pics/UserPicture2.png}
\end{minipage}
\end{center}
}
\begin{document}
\maketitle
\tableofcontents
\clearpage
\subsection{Digital to Analog}
This is correct
\subsubsection{Teori}
\begin{figure}[!h]
\centering\includegraphics[width=7cm,height=7cm]{pics/DSP/DAC/R2R-schematic.png}
\caption{R2R diagram}%
\label{fig:R2R-diagram}
\end{figure}
Figur \ref{fig:R2R-diagram} This text is indented with the normal paragraph indent.
Make it long enough to wrap to the next line and you'll see that.
\subsection{test}
This is correct
\end{document}
编辑:
我用最小版本更新了这个问题
我的代码如下:
\documentclass[11pt,a4paper,titlepage]{article}
%packs
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{fourier}
\usepackage{titling}
\usepackage{fancyhdr}
\usepackage[margin=1in,headsep=.2in]{geometry}
\usepackage{subfig}
\usepackage[export]{adjustbox}
\usepackage{subfiles}
\usepackage{rotating}
\usepackage{relsize}
\usepackage{mathtools}
\pagestyle{fancy}
\date{\today}
\author{}
\title{Kursusopgave 5, 62738 Digital signalbehandling E16 }
%headers and footers
%\rhead{\includegraphics[width=3cm]{pics/DTUlogo.png}}
\lhead{}
\renewcommand{\headrulewidth}{2pt}
\setlength{\headheight}{52.16212pt}
%
\posttitle{%
\begin{center}
\begin{minipage}[b]{0.4\textwidth}
%\includegraphics[width=6cm]{pics/UserPicture.png}
\end{minipage}
\qquad
\begin{minipage}[b]{0.4\textwidth}
%\includegraphics[width=6cm]{pics/UserPicture2.png}
\end{minipage}
\end{center}
}
\begin{document}
\maketitle
\clearpage
\subsection{Digital to Analog}
This is correct
\subsubsection{Teori}
\begin{figure}[!h]
\centering\includegraphics[width=7cm,height=7cm]{pics/DSP/DAC/R2R-schematic.png}
\caption{R2R diagram}%
\label{fig:R2R-diagram}
\end{figure}
Figur \ref{fig:R2R-diagram} This text is wierd
\subsection{test}
This is correct
\end{document}
并产生如下结果
原始问题
我正在用 LaTeX 写我的第一份作业,但是遇到了一些问题。
我觉得我无法控制文本对齐,如果你看下面的图片,你会看到文本的边距与其他部分不同。
此外,如果我选择自己换行,它也会产生一些奇怪的对齐,如第二张图片所示。
我已在文章末尾附上第一张图片的代码。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DAC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\clearpage
\subsection{Digital to Analog}
DAC'en skal omsætte et digitalt signal til et analogt signal. Her kommer et eksempel på et sådant kredsløb
\subsubsection{Teori}
\begin{figure}[!h]
\center{\includegraphics[width=7cm,height=7cm]{pics/DSP/DAC/R2R-schematic.png}}
\caption{R2R diagram}
\label{fig:R2R-diagram}
\end{figure}
Figur \ref{fig:R2R-diagram} viser et diagram over en 3-bit DAC opbygget efter R2R princippet.
Systemet giver en spænding mellem $0$ til $\sim5V$. For hver bit der bliver trukket høj, stiger
spændingen.
MSB giver den største spænding (cirka $50\%$ af max), mens LSB giver den mindste spændings
ændring. Udgangen svarer til summen af alle tændte bits.
编辑:
此外,我的文档中还有 3 个警告可能正在发挥作用。
Extra }, or forgotten \endgroup.
\maketitle ...\@bspretitle \@title \@bsposttitle }
\maketitlehookb {\@bsprea...
l.52 \maketitle
I've deleted a group-closing symbol because it seems to be spurious, as in `$x}$'. But perhaps the } is legitimate and you
forgot something else, as in `\hbox{$x}'. In such cases the way to
recover is to insert both the forgotten and the deleted material,
e.g., by typing `I$}'.
LaTeX Error: \begin{center} on input line 52 ended by \end{titlepage}.
See the LaTeX manual or LaTeX Companion for explanation. Type H
<return> for immediate help. ...
。
l.52 \maketitle
Your command was ignored. Type I <command> <return> to replace it with another command, or <return> to continue without
it.
LaTeX Error: \begin{titlepage} on input line 52 ended by
\end{document}. See the LaTeX manual or LaTeX Companion for
explanation. Type H <return> for immediate help. ..
。
l.110 \end{document}
Your command was ignored. Type I <command> <return> to replace it with another command, or <return> to
continue without it.
第 51-53 行如下所示
\begin{document}
\maketitle
\tableofcontents
答案1
看来当你有的时候你也\posttitle
必须有。\pretitle
正如 ebo 在评论中提到的,文本并不奇怪,只是用标准段落缩进缩进。默认情况下,紧接着节标题开始的段落不会缩进。我建议保留段落缩进。如果您真的不想要它,而是希望有一些垂直空间来指示新段落的开始,请添加\usepackage{parskip}
。
另外,您已经加载了amsmath
三次(mathtools
loads amsmath
),这是没有必要的。
请注意,在下面的代码中,我将其[demo]
作为选项添加到graphicx
包中,因为我没有图像。您需要将其删除。
\documentclass[11pt,a4paper,titlepage]{article}
%packs
\usepackage[utf8]{inputenc}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[demo]{graphicx}
\usepackage{fourier}
\usepackage{titling}
\usepackage{fancyhdr}
\usepackage[margin=1in,headsep=.2in]{geometry}
\usepackage{subfig}
\usepackage[export]{adjustbox}
\usepackage{subfiles}
\usepackage{rotating}
\usepackage{relsize}
\usepackage{mathtools}
\pagestyle{fancy}
\author{}
\title{Kursusopgave 5, 62738 Digital signalbehandling E16 }
%headers and footers
%\rhead{\includegraphics[width=3cm]{pics/DTUlogo.png}}
\lhead{}
\renewcommand{\headrulewidth}{2pt}
\setlength{\headheight}{52.16212pt}
%
\pretitle{\begin{center}\Large}
\posttitle{%
\par\medskip\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=6cm]{pics/UserPicture.png}
\end{minipage}
\qquad
\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=6cm]{pics/UserPicture2.png}
\end{minipage}
\end{center}
}
\begin{document}
\maketitle
\clearpage
\subsection{Digital to Analog}
This is correct
\subsubsection{Teori}
\begin{figure}[!h]
\centering\includegraphics[width=7cm,height=7cm]{pics/DSP/DAC/R2R-schematic.png}
\caption{R2R diagram}%
\label{fig:R2R-diagram}
\end{figure}
Figur \ref{fig:R2R-diagram} This text is indented with the normal paragraph indent.
Make it long enough to wrap to the next line and you'll see that.
\subsection{test}
This is correct
\end{document}